While or For with looping contructs? to create files from contents of a text file

Hi so far I created this script:

vi loop.beta.sh
 
for i in `cat extract.filenames.tabc`
do
        echo $i 
done>$i

===
This is the original text file.

[localuser@localhost ~]$ more tabc.txt
-rwx------- 1 alice   staff     1586  2010-11-05 02:27 request-key
.conf
-rwx------- 1 ted   staff     126  2011-04-29 13:54 cvs-pserver.co
nf
-rwx------- 1 carol   staff     644  2011-03-06 21:58 ts.conf
-rwx------- 1 alice   staff     17268  2011-04-29 13:54 devscripts
.conf
-rwx------- 1 bob   staff     34  2011-04-29 05:18 ld.so.conf
-rwx------- 1 bob   staff     92  2011-04-23 02:45 host.conf
-rwx------- 1 bob   staff     4794  2011-04-22 12:14 hdparm.conf
-rwx------- 1 bob   staff     1308  2011-04-19 02:06 kerneloops.co
nf
-rwx------- 1 bob   staff     552  2011-04-13 15:01 pam.conf
-rwx------- 1 bob   staff     322  2011-03-22 10:50 blkid.conf
-rwx------- 1 bob   staff     2724  2011-02-06 22:18 reportbug.con
f
-rwx------- 1 bob   staff     166  2011-01-04 22:46 tidy.conf
-rwx------- 1 bob   staff     1132  2010-12-12 12:47 smi.conf
-rwx------- 1 bob   staff     884  2010-11-05 00:56 insserv.conf
-rwx------- 1 alice   staff     168  2011-06-26 11:38 kernel-img.c
onf
-rwx------- 1 alice   staff     512  2011-04-29 05:27 nsswitch.con

===

#I then spliced out the last field in order to extract filenames
# Now I don't know how I can make files consecutively line by line using # these as their filenames???
# Should I use touch? Please help!

[localuser@localhost ~]$ more extract.filenames.tabc
request-key.conf
cvs-pserver.conf
ts.conf
devscripts.conf
ld.so.conf
host.conf
hdparm.conf
kerneloops.conf
pam.conf
blkid.conf
reportbug.conf
tidy.conf
smi.conf
insserv.conf
kernel-img.conf
nsswitch.conf
ca-certificates.conf
ntp.conf
updatedb.conf
libao.conf
deluser.conf
uniconf.conf
sysctl.conf
mtools.conf
preload.conf
netscsid.conf
resolv.conf
pnm2ppa.conf
gai.conf
debconf.conf
cowpoke.conf
logrotate.conf
ffserver.conf
sensors3.conf
popularity-contest.conf
cvs-cron.conf
adduser.conf

===

Please help on how to create files in home directory with the contents of line by line of the above extracted files???

Thank you

---------- Post updated at 02:25 AM ---------- Previous update was at 02:14 AM ----------

Do I have to clarify or retype this post so I someone can take a look at it?

There are several approaches possible. This way you can leave out the cat -command. Try this:

while read LINE; do touch $LINE; done < extract.filenames.tabc
1 Like

It doesn't have to be while?? I was thinking before that I might have to make looping contruct with something like >i++ and i=1 or something but I don't know how to apply it to these...

I will try this method though

Thanks again!:smiley:

In fact a combination of your first step with cut and the touch can look like this:

# awk '{print $NF}' infile| xargs touch