开发者

cp using awked lines

开发者 https://www.devze.com 2023-02-08 19:46 出处:网络
var=$(pwd);diff -x .DS* -r aa bb | c开发者_如何学Pythonut -f3,4 -d\' \'| sed \'s/\\://\' | awk -v \"var=$var\" \'BEGIN{OFS=\"/\"} {split($2,a,\"-\"); a[1]=toupper(a[1]) if ($1 ~/^bb/) {print var, $1,
var=$(pwd);diff -x .DS* -r aa bb | c开发者_如何学Pythonut -f3,4 -d' '| sed 's/\://' | awk -v "var=$var" 'BEGIN{OFS="/"} {split($2,a,"-"); a[1]=toupper(a[1]) if ($1 ~/^bb/) {print var, $1, $2 " " var, "aa"} 
else {print var, $1, $2 " " var, "bb"}}' | cp -r $(cut -f1 -d" ") $(cut -f2 -d" ")

This compares two directories and returns source and target addresses for copying purposes. The intended result is that both folders end up with the same files and folders inside them.

The cp-cut part doesn't work. Doing the cp manually produces the right result. The cut operations output seems OK.

Leaving off the cp-cut clause, the script produces lines like this

/Users/tom/Desktop/aa/AWK/awk-parse-email-add-or.textClipping /Users/tom/Desktop/bb

So this is the raw material - source file and target directory - to copy the awk clipping to the folder bb.

Could some kind person suggest where I am going wrong ?

Tom


You're using command substitution, $(cut -f1 -d" ") and $(cut -f2 -d" "), but these commands are not valid because cut requires input.

Try using xargs instead. Change your last pipe to:

| xargs -n 2 cp -r 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号