- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script writting
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
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
тАО03-18-2007 09:50 PM
тАО03-18-2007 09:50 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2007 10:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2007 10:10 PM
тАО03-18-2007 10:10 PM
Re: Script writting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 01:34 PM
тАО03-19-2007 01:34 PM
Re: Script writting
it is strange that I try it in two machines , one is perfectly work , but another machine can only show the word "testing" in the result ( what I need is the file name not the word I search ) , can advise what is wrong in this machine ? thx
$find . -type f -maxdepth 1 |xargs grep testing|awk -F ":" '{print $1}' |uniq
testing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 02:11 PM
тАО03-19-2007 02:11 PM
Re: Script writting
On the other machine there must have been more than one matches for the find, and xargs gives more than 1 input file to grep, and grep then knows it needs to tell you which file gave the match.
You can force this using: grep -H for --with-filename
(on my version of grep. Check with grep --help)
hth,
Hein van den Heuvel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 02:59 PM
тАО03-19-2007 02:59 PM
Re: Script writting
It works fine now after add -H , I still have a question , if I want to move it to another directory , I try
find . -type f -maxdepth 1 |xargs grep testing|awk -F ":" '{print $1}' |uniq |xargs mv /tmp/ora , it is not work , can advise what is wrong ? thx
mv: cannot overwrite non-directory `./abc' with directory `/tmp/ora/'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 03:49 PM
тАО03-19-2007 03:49 PM
Re: Script writting
It combines multiple arguments for one operation. That's fine for 'rm' but tricky for 'mv'.
Just replace the 'mv' with 'echo' and see in clear print what you were about to ask the system to do!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 04:06 PM
тАО03-19-2007 04:06 PM
Re: Script writting
I am not too understand , can advise what I need to do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2007 09:16 PM
тАО03-19-2007 09:16 PM
Re: Script writting
I have solved it , thx much for help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-20-2007 10:03 AM
тАО03-20-2007 10:03 AM
Re: Script writting
find /tmp -type f -exec grep "testing" {} \; -exec mv {} /other/path/ \;
Same format can be used for the 'rm'.