0

Say, I have a list.txt contained the names:

Book Summary to Complete
Jargon to Collect
Open Problem to Solve
Wordlist to Filter
...
etc
  1. How can I create files with its names saved in list.txt?
  2. For more usage, say the list.txt is updated period, how can I create the rest of files as soon as list.txt updated?

Thanks

1 Answers1

0

How can I create files with its names saved in list.txt?

You can either loop through the output of cat

 cat "list.txt" | while read LINE; do
     touch "./${LINE}"
 done

or make read read from file descriptor other than standard input

 while read -u 4 LINE; do
     touch "./${LINE}"
 done 4<list.txt

There might be lots of solutions though.

Just remember to enclose your variable references in double quotes and curly braces as long as the value of your variable may contain spaces.

For more usage, say the list.txt is updated period, how can I create the rest of files as soon as list.txt updated?

Basically this can be achieved by something monstrous like checking for changes in file in an infinite loop, but I doubt this is what you want.

Can you be more descriptive? How and where do you want to use your list.txt file?