How do I use 1 Column of a CSV File to Instruct/Confine a MV or CP command?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do I use 1 Column of a CSV File to Instruct/Confine a MV or CP command?
# 1  
Old 07-07-2010
Question How do I use 1 Column of a CSV File to Instruct/Confine a MV or CP command?

Please forgive my blatant ignorance, and thank you in advance for reading.

I am trying to move or copy files as contained in a one row csv document. So essentially I want to instruct a cp or mv command with a csv that will tell terminal/the command what files to grab and copy or move. IE, I want to move a bunch of files from a particular directory, but not ALL.

Any help or insight would be greatly appreciated.

Thanks again, have a great night.
# 2  
Old 07-08-2010
Try something like...
Code:
tr , \\n < input.csv | while read file; do mv "$file" /path/to/destination; done


Last edited by Ygor; 07-08-2010 at 04:50 AM..
This User Gave Thanks to Ygor For This Post:
# 3  
Old 07-09-2010
Code:
cat file | awk '{ split($0,temp," "); print "mv " temp[1] "Desination" }'

you can pass this to a shell script and can run that script to mv or cp

Last edited by Scott; 07-09-2010 at 09:59 AM.. Reason: Please use code tags
This User Gave Thanks to sjc For This Post:
# 4  
Old 07-09-2010
Code:
mvf() 
{ 
  IFS=, read line
  set -- $line
  mv "$@" /path/to/dir }
}
mvf < infile

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 07-12-2010
Thanks so much Ygor/SJC/Scrutinizer, off to try these out now. Mucho appreciated!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compare every column from one csv file to another csv file

1.csv contains following column- Empid code loc port 101 A xy 01 102 B zx 78 103 A cg 12 104 G xy 78 2.csv contains follwing data- Empid code loc port 101 A gf 01 102 B zx 78 103 C cg 32 104 ... (1 Reply)
Discussion started by: rishabh
1 Replies

2. Shell Programming and Scripting

Get maximum per column from CSV file, based on date column

Hello everyone, I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this: 20170628-23:25:01,1,0,0,1,1,1,1,55,55,1 20170628-23:30:01,1,0,0,1,1,1,1,56,56,1 20170628-23:35:00,1,0,0,1,1,2,1,57,57,2 20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies

3. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

4. Shell Programming and Scripting

Column with New Line in CSV file

Hello, Got a CSV file which contains 21 columns Need to convert the file to Pipe delimiter and Few columns text data contains new line Example 1,2,3,"ABC" 8" ABC,5,6,7 1,2,3,"ABC" 8" ABC,5,6,7 ( New Line) 1,2,3,""ABC" 8" ABC", 5,6,7 1,2,3,"ABC" ,5,6,7(New line) Expected... (8 Replies)
Discussion started by: krux_rap
8 Replies

5. Shell Programming and Scripting

First 4 Characters of a column in CSV file

Hi All, I have a CSV file in the below format: Id,Text,File "123","This is unix file","Unix" "121","This is C file","C" Want to have output in below format: Id,Text,File "123","This","Unix" "121","This","C" File is , separator with each fields in quotes. Some fields are having... (4 Replies)
Discussion started by: Sufer
4 Replies

6. Shell Programming and Scripting

CSV file column separator

Hi, I have a CSV file of 40 columns with "," as delimiter. I want to assign the value of each column to a variable. But some of the columns content inside contains "," so how can i split the columns and assign it to a variable. Regards, ARASU. (1 Reply)
Discussion started by: Arasu123
1 Replies

7. Shell Programming and Scripting

Remove the values from a certain column without deleting the Column name in a .CSV file

(14 Replies)
Discussion started by: dhruuv369
14 Replies

8. Shell Programming and Scripting

How to add a new column in a csv file?

Hi All, I would like to add a new column in my input.csv file as well as also want to add a new page in same .csv file. Plz help me any help should highly be appreciated...:) (8 Replies)
Discussion started by: Ashish Singhal
8 Replies

9. Shell Programming and Scripting

Pick the column value based on another column from .csv file

My scenario is that I need to pick value from third column based on fourth column value, if fourth column value is 1 then first value of third column.Third column (2|3|4|6|1) values are cancatenated. Main imp point, in my .csv file, third column is having price value with comma (1,20,300), it has... (2 Replies)
Discussion started by: Ganesh L
2 Replies
Login or Register to Ask a Question