LinuxQuestions.org
Help answer threads with 0 replies.
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, 03: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, 03:27 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
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, 03:59 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,839

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Welcome back Yves - seems to have been a while since we've had the benefit of your knowledge.
 
Old 09-19-2011, 04: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:35 AM
sed/awk help Eppo Programming 19 04-09-2011 03:50 AM
awk or sed help cmontr Programming 16 05-14-2008 11:59 AM
awk and/or sed linux2man Linux - General 7 01-22-2007 11:02 AM
Sed and Awk Gins Programming 7 04-19-2006 11:32 AM


All times are GMT -5. The time now is 09:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration