- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- vi/sed/awk quetsion
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
08-01-2003 01:15 AM
08-01-2003 01:15 AM
I have a file containing 5 fields($1-$5) and I want to insert in the beginning of $2 & $3 a "0".Anyone know how best to do this in vi/sed/awk?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 01:19 AM
08-01-2003 01:19 AM
Re: vi/sed/awk quetsion
No worries, sorted issue, I will do following:
cat file| awk '{print $1,"0"$2,"0"$3,$4,$5}'
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 01:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 01:22 AM
08-01-2003 01:22 AM
Re: vi/sed/awk quetsion
If the fields $2 and $3 have some pattern that vi can handle you can do it with vi, is quicker than other methods.
On the other hand you can do it with awk like this:
awk '{printf("%s 0%s 0%s %s %s\n", $1,$2,$3,$4,$5)}' file_in > file_out
and rename the file_out to file_in
I assume the separator filed is the space bar.
HTH
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 01:25 AM
08-01-2003 01:25 AM
Re: vi/sed/awk quetsion
awk '{print $1, 0$2, 0$3, $4, $5}'
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 01:30 AM
08-01-2003 01:30 AM
Re: vi/sed/awk quetsion
Al the above replies deserve 10 pts. If you would assign points it would be much appriciated by all who answer questions & contribute to the forums.
Points are what make this forum work & shows the author's sincere appriciation.
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2003 03:09 AM
08-01-2003 03:09 AM
Re: vi/sed/awk quetsion
cat file | awk '{print $1,"0"$2,"0"$3,$4,$5}' > newfile