- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: general scripting question
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
08-09-2007 12:46 AM
08-09-2007 12:46 AM
when I run a for statement and the line contains more than one field ...
can this line be displayed as 2 fields within a variable
ie
for aa in `ls -l`
do
echo $aa
done
root
system
705381
09
Aug
13:41
sortaudit4ge.aug09
-rw-r--r--
1
root
system
33280129
09
Aug
13:41
this is just and example btw.
Thanks
Chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 12:54 AM
08-09-2007 12:54 AM
Re: general scripting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 12:54 AM
- Tags:
- IFS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 01:01 AM
08-09-2007 01:01 AM
Re: general scripting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 01:05 AM
08-09-2007 01:05 AM
Re: general scripting question
Thanks for responses and solution.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 01:07 AM
08-09-2007 01:07 AM
Re: general scripting question
When you munge the shell IFS in a script, it's good practice to do something like this:
#!/usr/bin/sh
OLDIFS=${IFS}
IFS="|"
...
...
IFS=${OLDIFS}
...
Regards!
...JRF...
BTW: the "root system" ownership looks like AIX :-))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 02:30 PM
08-09-2007 02:30 PM
Re: general scripting question
You can of course use while read instead of "for i in $(); do":
ll | while read a b c; do
The delimited tokens are put in "a", "b" and the rest in "c".
You can of course pipe the output to awk and use its -F to separate tokens.
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 08:11 PM
08-09-2007 08:11 PM
Re: general scripting question
Yes from the output it is AIX, I havent worked on a HP machine for 18 months now however moving jobs to a company that has 20 + HP servers ;=}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 08:11 PM
08-09-2007 08:11 PM