- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Manipulating a log with a Script
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-21-2003 10:27 AM
02-21-2003 10:27 AM
I am having a problem with a shell script??? since I am new on Shell scripting but right now learning a lot with your help???
I have a log file with this format (MRTG log file format) ;)
1045784114 60 59 60 59
1045783813 63 62 63 62
1045783800 62 61 63 62
Basically, I want to replace the space ??? ??? character with a comma ???,??? character, so I can export this file to a Database and read the contents with this CSV format.
Also, need to add a value in the beginning of each line, so the new file can be read like this:
Hostname,1045784114,60,59,60,59
Hostname,1045783813,63,62,63,62
Hostname,1045783800,62,61,63,62
I tried more, and cat, but cant get this working???
Any help or hints will be really appreciated.
Rogelio
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:31 AM
02-21-2003 10:31 AM
Re: Manipulating a log with a Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:35 AM
02-21-2003 10:35 AM
Re: Manipulating a log with a Script
$ cat file|sed 's/^/Hostname,/'|sed 's/ /,/g'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:36 AM
02-21-2003 10:36 AM
Re: Manipulating a log with a Script
sed 's/^/hostname/'
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:49 AM
02-21-2003 10:49 AM
Re: Manipulating a log with a Script
Here's another way:
# awk -v hostname=$(hostname) 'BEGIN{ OFS=","};{$1=$1;print hostname,$0}' filename
In this case the actual server hostname is injected into the output lines.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 10:50 AM
02-21-2003 10:50 AM
Re: Manipulating a log with a Script
Sridhar's command made the whole job in one step, thank you very much.
Best regards.
Rogelio