- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: direct execution of many similar commands
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
Discussions
Discussions
Discussions
Forums
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
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
тАО04-18-2001 09:26 AM
тАО04-18-2001 09:26 AM
frequently I get to run a command on a number of files or parameters that come from a file. Usually I do something like:
ls -1 | awk ?{print "my_script " $0 }' > execfile
or
cat datafile | awk ..... > execfile
This works fine but not all at once. i.e. I have to run the execfile aftrwards.
and because time is money I am looking for an on line execution of this sequence of commands that is generated by the above lines without the need of an additional execfile.
How can I tell the shell (ksh) to run all commands directly as they come out of the awk.
Must be something with "command substitution" such as ` ` or $(... ) ?
any ideas ?
thanks
Klaus
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 09:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 10:23 AM
тАО04-18-2001 10:23 AM
Re: direct execution of many similar commands
ls -1 | awk ?{print "my_script " $0 }' > execfile
cat execfile | while read line
do
${line}
done
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 10:47 AM
тАО04-18-2001 10:47 AM
Re: direct execution of many similar commands
cd /dir
for i in `ls -1`
do
/other_dir/my_script $i
done
or
cd /dir
ls -1 > datafile
for i in `cat datafile`
do
/other_dir/myscript $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 11:51 AM
тАО04-18-2001 11:51 AM
Re: direct execution of many similar commands
By way of example, how about something like this:
# ls -l|awk 'NR != 1 {system ("grep token " $9)}'
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 12:09 PM
тАО04-18-2001 12:09 PM
Re: direct execution of many similar commands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 01:11 PM
тАО04-18-2001 01:11 PM
Re: direct execution of many similar commands
And one more possibilty:
ls -1 | while read name
do
my_script $name
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 04:00 PM
тАО04-18-2001 04:00 PM
Re: direct execution of many similar commands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2001 11:02 PM
тАО04-18-2001 11:02 PM
Re: direct execution of many similar commands
ls -1 | awk '{ system("my_prog" $0)}'
or
ls -1 | awk '{print "my_prog " $0}'| sh
federico