LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-21-2014, 04:42 AM   #1
projectrevo
LQ Newbie
 
Registered: Jun 2014
Posts: 1

Rep: Reputation: Disabled
Question Simplifying single-line command with cut & paste


I have a file "data" with the following text:
Quote:
1425 Juan 14.25
4321 George 21.11
6781 Anna 16.77
1451 Ben 21.77
2277 Tuan 18.77
In order to swap column 2 and 3, I did this single-line command:
Code:
$cut -f1 data > field1 && cut -f2 data > field2 && cut -f4 data > field4 && paste -d" " field1 field4 field2 > output
I was wondering how to simplify that line in any way.
 
Old 06-21-2014, 11:39 AM   #2
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
You can use awk
Code:
awk '{print $1" "$3" "$2}' data
 
  


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] is there a command for cut and paste? cristi92b Linux - Newbie 8 06-14-2011 04:57 PM
fixing cut & paste Skaperen Linux - Desktop 3 12-21-2010 05:08 PM
Cut and paste from command line dulli1 Linux - Newbie 9 10-12-2010 10:31 PM
Cut & Paste Rick069 Linux - General 1 04-15-2005 05:58 PM
Cut & paste to browser fend88 Linux From Scratch 2 04-27-2002 10:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

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