LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2011, 02:01 AM   #1
yimaizhe
LQ Newbie
 
Registered: May 2011
Posts: 11

Rep: Reputation: Disabled
something about awk or sed ?


I have a big txt file,nearly 1Gb,and it contains 1000 rows and 1000 lines

now i want to delete 8th row(suppose),how should i do it ?
thanks
 
Old 09-19-2011, 02:27 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
What is the difference between a row and a line?
To delete the 8th line/row, you run “sed -ibak 8d /path/to/your/file”; your file will be modified, and you’ll have a backup file with the “bak” extension.
To delete the 8th column, you’ll have to play with awk instead, by correctly specifying the field separator, and outputing each line minus the 8th column.

Yves.
 
1 members found this post helpful.
Old 09-19-2011, 02:59 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Welcome back Yves - seems to have been a while since we've had the benefit of your knowledge.
 
Old 09-19-2011, 03:48 AM   #4
yimaizhe
LQ Newbie
 
Registered: May 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theYinYeti View Post
What is the difference between a row and a line?
To delete the 8th line/row, you run “sed -ibak 8d /path/to/your/file”; your file will be modified, and you’ll have a backup file with the “bak” extension.
To delete the 8th column, you’ll have to play with awk instead, by correctly specifying the field separator, and outputing each line minus the 8th column.

Yves.
thanks a lot ,it works well ,and i am sorry for my unclear explaination
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk/sed help mailvaganam Programming 5 05-03-2011 12:35 AM
sed/awk help Eppo Programming 19 04-09-2011 02:50 AM
awk or sed help cmontr Programming 16 05-14-2008 10:59 AM
awk and/or sed linux2man Linux - General 7 01-22-2007 10:02 AM
Sed and Awk Gins Programming 7 04-19-2006 10:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:54 AM.

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