- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Creating files from ls -l list
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2002 11:31 PM
06-02-2002 11:31 PM
I have the following script for getting the list of subfilesystems under a particular filesystem. The list of parent filesystems are in the file CPUlist.
#cat CPUlist
/fs12
/fs13
/fs14
/fs15
/fs16
/fs19
/fs23
/fs31
/fs34
/fs36
/fs37
/stor
#cat getFS.sh
#!/bin/sh
for i in `cat CPUlist`
do
ls -l $i > /tmp/pgfs1/SYNC/i.txt
done
Whenever the shell tries to create a file under /tmp/pgfs1/SYNC/, it would produce the following error:
A file or a directory in the path does not exist:
./getFS.sh[5]: /tmp/pgfs1/SYNC/i.txt : 0403-005
cannot create the specified file.
Could someone help out in this question?
I would like to have the names of the files created under /tmp/pgfs1/SYNC/ to bear the names of the all filesystem list in CPUlist i.e. fs37.txt, fs36.txt, etc... fs12.txt.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2002 11:40 PM
06-02-2002 11:40 PM
Re: Creating files from ls -l list
what you did in your script is to redirect the output of your ls- command into a file. To get all entries of your listing into the file, use the following syntax:
ls -l Si >> /tmp/pgfs1/SYNC/i.txt
otherwhise the entries will be overwritten. To create files without contenst, you can use the touch- command, and if you want to add .txt to the name, use the following command in your loop:
touch "$i.txt"
If you need a path, put it in front of your desired name.
touch "/tmp/pgfs1/SYNC/$i.txt"
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2002 11:49 PM
06-02-2002 11:49 PM
Re: Creating files from ls -l list
Exist the directory?
if not you can must create it before.
You must use >> if you don't want to overwrite the contents of the file.
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 12:00 AM
06-03-2002 12:00 AM
Re: Creating files from ls -l list
I had only wanted have the contents(ls -l) of the filesystem names as listed in file CPUlist to be redirected into another file.
I made changes to the line begining with ls -l ...
to become:
ls -l $i > /tmp/pgfs1/SYNC/.$i.txt
OR
I also tried removing the slashes '/' from the CPUlist file, and changed the line below in my script:
ls -l /$i > /tmp/pgfs1/SYNC/$i.txt
Neither both ways worked.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 12:02 AM
06-03-2002 12:02 AM
Solutiontry
#!/bin/sh
cat getFS.sh|while read dir
do
ls -l $dir > /tmp/pgfs1/SYNC/$dir".txt"
done
Also check that each part of the directory
path till SYNC exists and can be written by
the user running the script.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 12:04 AM
06-03-2002 12:04 AM
Re: Creating files from ls -l list
Try protecting the variables:
ls -l /${i} > /tmp/pgfs1/SYNC/${i}.txt
Regards,
Justo.
Note: Do you have enough permits on the directory?