- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: UNIX script help
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
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
06-18-2002 06:18 AM
06-18-2002 06:18 AM
UNIX script help
How do I put this in a script
%s/\[//
to remove all [ in a file.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:21 AM
06-18-2002 06:21 AM
Re: UNIX script help
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:22 AM
06-18-2002 06:22 AM
Re: UNIX script help
You could use 'tr':
# tr -d "[" < filename > filename.new
Regards!
...JRF....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:27 AM
06-18-2002 06:27 AM
Re: UNIX script help
perl -i -p -e 's/\[//g' file1 file2 ...
or cd to desired directory
perl -i -p -e 's/\[//g' x*
to edit all files that begin with x.
No temp files or input output redirection needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:33 AM
06-18-2002 06:33 AM
Re: UNIX script help
I suppose I should have added if you add a suffix to the -i a backup file is also created for you automatically.
perl -i.save -p -e 's/\[//g' x*
to edit all files that begin with x.
THat would put the changes in files x1, x2, ...
and the backups would be x1.save, x2.save, ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:36 AM
06-18-2002 06:36 AM
Re: UNIX script help
l1:/tmp 105 > cat xx.txt
blah[1]
l1:/tmp 106 > perl -pi -e 'tr/[//d' xx.txt
l1:/tmp 107 > cat xx.txt
blah1]
l1:/tmp 108 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:39 AM
06-18-2002 06:39 AM
Re: UNIX script help
To simply run the command, place it in a script as per the first reply.
If you want to build the search string in the script, then you will need to put a backslash before the backslash to get the shell to convert it to a non-special character.
eg sed 's/\\\[//g'
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 06:43 AM
06-18-2002 06:43 AM
Re: UNIX script help
cat filename | sed -e "1.$ s/\[//g" > new file
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2002 07:04 AM
06-18-2002 07:04 AM
Re: UNIX script help
sed 's/\[//g' (file name) > (new file name)
hope this helps
regds
ravi