- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script problem
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
10-16-2005 06:44 PM
10-16-2005 06:44 PM
I am doing some scripting, to copy some files source to destination.
I have about 25 files in current location, I want to copy all the files which starts from the letter a* ,out of which i don't want to copy a particular file which starts ae*
What I have written this
ls –al a* | grep –v ae | awk ‘{print $9}’
this is will give me the output, but i want to know how to copy all these files (i mean which comes as output of awk command)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:48 PM
10-16-2005 06:48 PM
Re: script problem
for a in `ls al a* | grep v ae | awk {print $9} `
do
cp $a /destination
done
Note the use of ` ` around your command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:52 PM
10-16-2005 06:52 PM
Re: script problem
for file in `ls -al a* | grep -Ev 'ae|total' | awk '{ print $9 }'`
do
cp -i ${file}
done
Note: Negate grep for total string for using ls -l
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:53 PM
10-16-2005 06:53 PM
Re: script problem
for file in `ls -al a* | awk '!/ae/{ print $9 }'`
do
cp -i ${file}
done
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:57 PM
10-16-2005 06:57 PM
Re: script problem
why we need ksh at the end, i am doing this bash
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 06:58 PM
10-16-2005 06:58 PM
Re: script problem
Will also do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 07:00 PM
10-16-2005 07:00 PM
Re: script problem
Also this eliminates the need for a loop.
Just use
cp /sourcedir/a[!e]* /destdir/
for local or
scp /sourcedir/a[!e]* remote_host:/destdir/
for remote copying.
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 07:03 PM
10-16-2005 07:03 PM
Re: script problem
it worked for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 07:03 PM
10-16-2005 07:03 PM
Re: script problem
ls -al a[!e]* | awk '{ print "cp "$9" /tmp" }' | bash
It will just work as a sub process to execute those copy operations.
ls -al a[!e]* | awk '{ print "cp "$9" /tmp" }'
will print the shell command that has to be executed. | bash will execute it.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 07:03 PM
10-16-2005 07:03 PM
Re: script problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2005 07:08 PM
10-16-2005 07:08 PM
Re: script problem
Hope you got the solution.
I have a serious comment as,
I have assigned points to 1 of 63 responses to my questions. from your profile.
You assigned only one point to all these responses. Plz assign points to all responses so that you will get good responses.
Every one is sharing their valuable technical time with you PROMPTLY.
hth.