malmo
malmo

Reputation: 524

use columns of a CSV file using awk

I have a CSV file that contains paths, I want to copy the files of the first column in the paths of the second column How I manage to do that using awk for example if I have the following csv

project/file1     ../project1/file1.old
project/file2     ../project1/file2.old
project2/file1    ../project3/file1.old

Upvotes: 0

Views: 128

Answers (1)

bprasanna
bprasanna

Reputation: 2453

Assuming the csv file src.csv with following contents:

project/file1,../project1/file1.old
project/file2,../project1/file2.old
project2/file1,../project3/file1.old

Following is the linux command using awk and shell script which copies all the files mentioned in the csv:

awk -F "," '{print "cp " $1 " "  $2}' < src.csv > copy_src_dest.sh; sh copy_src_dest.sh

Upvotes: 1

Related Questions