LinuxQuestions.org
Help answer threads with 0 replies.
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 09-04-2005, 09:46 AM   #1
hottdogg
Member
 
Registered: Aug 2004
Location: aisenodni
Distribution: slackware 64bit ,debian 64bit
Posts: 202

Rep: Reputation: 30
truncate a text file in CLI?


I'm not a linux expert, sorry for the dumb question.

How to truncate some lines in a file and put the result in created-by-fly new file.

For example, taking only line 43-50 from foo.txt and put the result in bar.txt where bar.txt is created directly in 1 command. Do you know what I mean?

Maybe using piping or redirection or something...I don't know.

Please help. Thx.
 
Old 09-04-2005, 10:53 AM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,533

Rep: Reputation: 178Reputation: 178
"How to truncate some lines in a file and put the result in created-by-fly new file.

For example, taking only line 43-50 from foo.txt and put the result in bar.txt where bar.txt is created directly in 1 command."

Use sed. The command would look something like:

sed -n '43,50p' foo.txt > bar.txt

See:
man sed

---------------------------
Steve Stites
 
Old 09-06-2005, 09:32 PM   #3
hottdogg
Member
 
Registered: Aug 2004
Location: aisenodni
Distribution: slackware 64bit ,debian 64bit
Posts: 202

Original Poster
Rep: Reputation: 30
thanks. Will try that
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Truncate A File Dovetails Linux - Newbie 2 10-22-2005 06:58 PM
Missing CLI text editors in Slack 10.0? X_ArchAngel Slackware 9 08-02-2004 09:10 PM
CLI based Text manipulation selfsck Linux - General 1 07-15-2004 07:11 PM
Zipslack 9.1 long file names truncate jimk Slackware - Installation 5 05-16-2004 06:38 AM
text color in the CLI hrc Linux - Software 7 06-25-2003 09:35 AM


All times are GMT -5. The time now is 05:50 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration