- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Interesting Scripting Question - Stdout and File R...
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
02-11-2002 02:45 AM
02-11-2002 02:45 AM
I know we can recreate a Variable and re-assign the value directly,
eg. export PATH=$PATH":/tmp"
BUT! Can I do the same in one command for a log file?
eg. grep -v "Alpha" /tmp/file1 >/tmp/file1
Or am I resigned to 2 commands?
eg. grep -v "Alpha" /tmp/file1 >/tmp/file2
mv /tmp/file2 /tmp/file1
Share and Enjoy! Ian
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 03:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 03:08 AM
02-11-2002 03:08 AM
Re: Interesting Scripting Question - Stdout and File Recreation
sorry, but you will indeed need an intermediate file if you use redirection.
If you really do not want an extra file, you could use and ed script:
ed yourfile << [EOT]
,g/searchstring/d
w
q
[EOT]
good luck,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 03:13 AM
02-11-2002 03:13 AM
Re: Interesting Scripting Question - Stdout and File Recreation
The tee trick indeed does the trick perfectly.
Just add "> /dev/null" to get rid of the output on screen (don't know how big the file is).
grep -v "Alpha" /tmp/file1 |tee /tmp/file1 > /dev/null
regards,
Thierry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 03:21 AM
02-11-2002 03:21 AM
Re: Interesting Scripting Question - Stdout and File Recreation
Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 03:44 AM
02-11-2002 03:44 AM
Re: Interesting Scripting Question - Stdout and File Recreation
You are welcome Mister.
Best Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 04:31 AM
02-11-2002 04:31 AM
Re: Interesting Scripting Question - Stdout and File Recreation
Be aware that the tee trick only works for small amounts of data.
tee is useful because you specify the output filename as an argument, if you had to use >
Some tests that I have done indicate that you will get away with writing between 18 and 24Kb but personally I wouldn't trust it unless you're sure that the input file is very small.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2002 04:36 AM
02-11-2002 04:36 AM
Re: Interesting Scripting Question - Stdout and File Recreation
Thanks for the warning, will definitely check sizings before using this methodology.
Ian