LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-13-2004, 02:59 PM   #1
SeT
Member
 
Registered: Dec 2002
Location: cincinnati
Posts: 87

Rep: Reputation: 15
sed or other formatting command help


I've got a complex sed command written that doesn't seem to be working correctly. I don't see anything wrong with it but it's not formatting the way it should it seems and it's pulled numbers out of nowhere. Command as is:

Code:
sed -e "s/\([1-9]*\)\(.\)\([1-9]*\)\(.\)\([1-9]*\)\(,\)\([1-9]*\)\(.\)\([a-z]*\)\(,\)\([1-9]*\)/\1\2\3\4\5      \7       \9       \11/" tmp >> diskhog
file before:

1 000-0001,85246708 user,37062956
2 000-0002,39100916 user,15359912
3 000-0003,46756052 user,95710112
4 000-0004,19719784 user,28267676
5 000-0005,22113236 user,11721556

file after:

Code:
1 000-0001,85246708 user,37062956
2 000-0002,39100916 user,15359912
3 000-0003,46756052 user,95710112
4 000-0004       19719784       user      3481
5 000-0005       22113236       user       3481

seems to not be touching the first three lines at all and pulling "3481" out of nowhere. Any ideas what's going on/help/better ideas than such a complex sed?

Last edited by SeT; 10-13-2004 at 03:12 PM.
 
Old 10-13-2004, 06:57 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Maybe this is more what you have in mind. the tabs are made with \t
Code:
sed -e 's/\([0-9]*\) \([0-9]*\)-\([0-9]*\),\([0-9]*\) \([[:alnum:]]*\),\([0-9]*\)/\1\ \2\-\3\t\4\t\5\t\6/' file.txt > diskhog.txt
Here's a more compact version
Code:
sed -e 's/\([[:alnum:]]*\),\([0-9]*\) \([[:alnum:]]*\),\([0-9]*\)/\1\t\2\t\3\t\4/' file.txt > diskhog.txt

Last edited by homey; 10-13-2004 at 07:32 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command Kalyani1 Linux - Software 28 12-07-2005 11:48 AM
sed command pazvant Linux - Software 2 05-09-2004 12:58 PM
sed command linuxdev Linux - Newbie 9 02-24-2004 04:50 PM
sed Command linuxdev Linux - Newbie 3 02-09-2004 11:27 AM
sed command kwigibo Linux - General 3 04-21-2002 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration