LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-04-2008, 02:28 AM   #1
phsythax
Member
 
Registered: Oct 2005
Location: Denmark
Distribution: Gentoo & XP pro for gaming
Posts: 152

Rep: Reputation: 30
Question scripting


I've got a large text file, and i would like to replace some strings on each line, e.g.

i've got lines like these:

a b c
a b c
a b c

i would like to move the strings so that the lines end up looking like this:

b a c
b a c
b a c

"b", "a" and "c" are just variables, the actual content change, but the positioning of the content are the same.

My question is, What commands should i use to solve my problem?
 
Old 06-04-2008, 02:32 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If the strings are structured like records, you can easily use awk to print out the fields in any order you want.

Last edited by jschiwal; 06-04-2008 at 07:45 PM. Reason: typo: structures -> structured
 
Old 06-04-2008, 07:22 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Are you trying to change things based on position or content? e.g., do you want to:

--move all occurrences of "b" to the front.

OR

--move the second field to the front.
 
  


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
new in scripting bob4linux Programming 10 10-27-2007 05:54 PM
Scripting help please Decorte Linux - Newbie 3 10-21-2007 06:31 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
scripting help Abe_the_Man Linux - General 1 11-03-2004 05:30 PM
HELP!! with scripting eggoz Linux - General 1 04-25-2003 07:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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