Computing.Net > Forums > Unix > Unix: File manipulation

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix: File manipulation

Reply to Message Icon

Name: esu (by Raj)
Date: June 14, 2007 at 10:14:02 Pacific
OS: Linux
CPU/Ram: 64
Product: red
Comment:

Hi All,

Could somone suggest the solution for this problem?

The problem is that I have a abc.txt file in following format. Requiremnt is to:
1) get rid of top(first)line from file.
2) remove the extra white space from beginning of each line in file.
3) Remove the white space after word 'status' and before 'time' is displayed.

Here's how current file looks like:

NameTestsErrorsFailuresTime(s)
testLoginInitialLoad Success 7.938
testFailedSignOn Success 7.156
testLoginSignOn Success 8.078
testHomeTabNone Success 16.469

==================================
expected output should be :

testLoginInitialLoad Success 7.938
testFailedSignOn Success 7.156
testLoginSignOn Success 8.078
testHomeTabNone Success 16.469


==================================

You may not see the space in inmessage I posted but assume that there's space at beginning of each line and extra space after status.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: June 14, 2007 at 22:53:11 Pacific
Reply:

Look at Eric Pement's sed one-liners. I think he answers all of your questions:

http://www.student.northpark.edu/pe...


0

Response Number 2
Name: Shell_Life
Date: June 25, 2007 at 12:52:50 Pacific
Reply:

1) get rid of top(first)line from file:
tail +2 input_file

2) remove the extra white space from beginning of each line in file:
sed 's/^ //' input_file

3) Remove the white space after word 'status' and before 'time' is displayed.
sed 's/status /status/' input_file


Informix/4GL


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix: File manipulation

to see unix file system in windows www.computing.net/answers/unix/to-see-unix-file-system-in-windows/3206.html

problems with unix file system www.computing.net/answers/unix/problems-with-unix-file-system/7541.html

UNIX file system www.computing.net/answers/unix/unix-file-system/3086.html