Re: Executing series of commands for each entry in text file
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 07/27/04
- Next message: Chris F.A. Johnson: "Re: Bash problem with find and mv"
- Previous message: Chris F.A. Johnson: "Re: Remove Duplicates from List"
- In reply to: Joerg Loosen: "Executing series of commands for each entry in text file"
- Next in thread: Dana French: "Re: Executing series of commands for each entry in text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Jul 2004 09:31:14 GMT
On 2004-07-27, Joerg Loosen wrote:
> Hi there!
>
> I have a text file containing several entries like so:
>
> adam
> brian
> chuck
> ...
>
> There is one word per line. Now I would like to execute a series of unix
> commands for each entry like so:
>
> touch <entry>.txt
> move <entry>.txt <dir>
> ...
>
> with <entry> being replaced by the contents of the text file, e.g.:
> first 'adam' then 'brian' and so on. I could write a perl script but I
> was wondering if there was a simple "shell-only" solution. Btw my
> current shell is bash.
while IFS= read -r line
do
touch "$line.txt"
move "$line.txt" "$dir"
done < TEXTFILE
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: Chris F.A. Johnson: "Re: Bash problem with find and mv"
- Previous message: Chris F.A. Johnson: "Re: Remove Duplicates from List"
- In reply to: Joerg Loosen: "Executing series of commands for each entry in text file"
- Next in thread: Dana French: "Re: Executing series of commands for each entry in text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading