Sunday, July 12, 2015

linux - How to move the folders to new directory based on their match in csv file?

In my present directory I have many folders like F1, F2, F3, F4, F5, F6, F7, F8, F9, F10.




I have a csv file "dan.csv" in the present directory which has a column with folder names.



csv file looks like below: Column name is "id"



id
F1
F4
F5
F6

F8
F10


Based on their match in the csv file I would like to move the folders to a new directory "DAN".



To do this I tried like below:



xargs -a <(tail -n +2 dan.csv) -I{} sh -c '[ -d "{}" ] && mv -t DAN "{}"'



This didn't throw any error and also didn't move the folders into new directory "DAN".

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...