'cat' not allowing absolute filenames when piped to 'cut'
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
'cat' not allowing absolute filenames when piped to 'cut'
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.
Why are you calling export on the filesystem names? I think the export you are calling is the shell export for exporing shell variables. The filesystem names read from the file are not valid shell variables, so you are getting the error.
What I want to do is use these entries to define my variables which will be put into commands like mklv, crfs and the like. I've also begun trying to write a perl script to do this because in the near future I'll be working with many more (30+) filesystems at a time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.