I am trying to write a one line command to create 20 empty files with names extracted from a .txt file in another folder directory with the same txt extension.
I tried
for i in $(cat test.txt); do grep -w $i | touch $i.txt ; done
and
cat test.txt| while read line ; do grep $line ; touch $line.txt ; done
as well as
for filename in $(cat testfile.txt) ; do touch head -20 $filename.txt; done
It does not work. I do not know how to specify the 10 first words of the test.txt file.
for i in $(head test.txt); do touch $i.txt ; done
? – mikewhatever Oct 21 at 13:50test.txt
file - the format matters e.g. whether there is one word per line, multiple words per line etc. – steeldriver Oct 21 at 13:55for i in $(head -n 20 test.txt); do touch $i.txt ; done
, since you want 20 entries. – mikewhatever Oct 21 at 15:01