Skip to main content
Removed UUoC (useless use of cat); made safer for file names with spaces; there was no missing ';', that's not needed for multiline format like this
Source Link
terdon
  • 10.6k
  • 5
  • 23
  • 48

First of all youryou are getting an error because you are missing a ;then in the third line 3 of your code and then a fi to close the if. It should be:

for i in *.vcf
do if grep -q $i 1.txt; then
    cp *$out* /temp/hgig/fi1d18/TRG45/snp/snp/TRG/pre/
fi
done

And I guess the one-liner below achieves what you are trying to do:

 while IFS= catread file-list.txt | while readr line; do mv $line*"$line"*.vcf some-directory; done < file-list.txt 

First of all your are getting an error because you are missing a ; in line 3 of your code.

And I guess the one-liner below achieves what you are trying to do:

   cat file-list.txt | while read line; do mv $line*.vcf some-directory; done

First of all you are getting an error because you are missing a then in the third line of your code and then a fi to close the if. It should be:

for i in *.vcf
do if grep -q $i 1.txt; then
    cp *$out* /temp/hgig/fi1d18/TRG45/snp/snp/TRG/pre/
fi
done

And I guess the one-liner below achieves what you are trying to do:

while IFS= read -r line; do mv "$line"*.vcf some-directory; done < file-list.txt 
Source Link
haci
  • 4.2k
  • 1
  • 7
  • 28

First of all your are getting an error because you are missing a ; in line 3 of your code.

And I guess the one-liner below achieves what you are trying to do:

   cat file-list.txt | while read line; do mv $line*.vcf some-directory; done