LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-08-2012, 04:26 PM   #1
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27
Blog Entries: 2

Rep: Reputation: Disabled
awk/grep/sed/print......etc


The abc.txt file always 2 lines.
cat abc.txt
21321313
34343dfddf

Please help...what’s good command out put like below 1 line. The 2 lines come first then first line. Thanks

34343dfddf 21321313

This code not code not work:

Quote:
cat abc.txt | awk 'NR==2,NR==1' | tr -d '\n'
 
Old 08-08-2012, 04:38 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,445

Rep: Reputation: Disabled
This should work:
Code:
cat abc.txt | tr '\n' ' ' | awk '{print $2,$1}'
 
Old 08-08-2012, 04:41 PM   #3
dotran
LQ Newbie
 
Registered: Apr 2012
Posts: 27
Blog Entries: 2

Original Poster
Rep: Reputation: Disabled
Awesome....Thanks very much.
 
  


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
[SOLVED] replace grep -o with sed or awk nicomoresi Linux - Newbie 20 08-08-2011 11:13 AM
[SOLVED] bash- sed, awk, grep schneidz Programming 10 01-31-2011 08:56 PM
grep help or sed or awk dmchess Linux - Software 4 09-29-2010 06:53 PM
[SOLVED] Help using awk,sed and grep shakes82 Programming 34 07-07-2010 11:12 PM
help with grep/sed/awk nikunjbadjatya Programming 8 02-17-2010 07:29 PM


All times are GMT -5. The time now is 06:00 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