Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cat command not allowing "/" in filesystem names

Status
Not open for further replies.

d3funct

MIS
Jul 13, 2000
313
US
Hello,

I'm writing a script to create a filesystem layout on an AIX 5.1L Regatta using LVM. In this script I'm using a "for" loop to 'cat' a file and retrieve the filesystem name from the fourth field. The file I'm reading from looks like this:

VGName LVName LogName FileSystem LVSize

My forloop for the Filesystem looks like this:

for l in `cat layout.txt |cut -d" " -f4`
do FSN=$l
export $FSN
done


When I run the script it errors saying:
./Srwds.ksh[24]: /u02_01: is not an identifier

I know the slash (/) is the problem because if I remove them I do not get an error unless the filesystem I'm creating is something like opt/apps/somefile.

My question is how do I get around this? I need to create filesystems with absolute pathnames, and there are so many to create that putting them in a file and running the script is the best way to do it. Thanks for any and all suggestions. An infinite number of monkey typing at an infinite number of keyboards will eventually populate the internet.
 
I would have implemented it as:

cat filename.txt | awk '{print $4}' | while read FSN
do
have_a_party ${FSN}
done
 
while read junk junk junk FSN junk
do
have_a_party ${FSN}
done < filename.txt vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
for l in `cat layout.txt |cut -d&quot; &quot; -f4`
do FSN=$l
export $FSN
done


- man cut and discover
'cat file|cut -OPTS' and 'cut -OPTS file' are equivalent
- look also 'man export', the (ksh)syntax is 'export NAME=value'
- what's the pourpose of that 'for' ?
if the file has more then 1 line, FSN will be overwritted by
last value readed in
- for what is the variable 'l', why not 'for FSN in ....'
- stop defining variable-names by ONE letter, suppose
you have to change all ocurences of 'n' in a x-thousand
lines codefile.... make your life easier, use 'nnn'

shell-scripting is not difficult, there are tonnes of good books...


-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
UUOC:

> 'cat file|cut -OPTS' and 'cut -OPTS file' are equivalent vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top