Sponsored Content
Full Discussion: sort words in a line
Top Forums Shell Programming and Scripting sort words in a line Post 302326382 by durden_tyler on Wednesday 17th of June 2009 10:14:23 PM
Old 06-17-2009
Quote:
Originally Posted by rebelbuttmunch
...
Im looking for a way, hopefully a one-liner to sort words in a line

e.g

"these are the words in a line"
to
"a are in line the these words"

...
Code:
$
$ echo "these are the words in a line"|perl -ne '@x=split/\s/; print join " ",sort @x'
a are in line the these words$
$

Quote:
... although my line will have more than 9 terms, seperated by commas

e.g
csoTopic=Topics: Artists Exact Match, queryTerm=new kids on the block, defaultDisplayName=New Kids On The Block, topic=vid
eos, artistName=New Kids On The Block, weight=50,

I think Im gonna have to go down the road of splitting them in a temp file , ordering them, and joining them up again.
Code:
$
$ echo "csoTopic=Topics: Artists Exact Match, queryTerm=new kids on the block, defaultDisplayName=New Kids On The Block, topic=videos, artistName=New Kids On The Block, weight=50,"|perl -ne '@x=split/,\s*/; print join ", ",sort @x'
artistName=New Kids On The Block, csoTopic=Topics: Artists Exact Match, defaultDisplayName=New Kids On The Block, queryTerm=new kids on the block, topic=videos, weight=50$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get line number of different words if exists in same line

I have some txt files. I have to create another text file which contains the portion starting from the format "Date Sex Address" to the end of the file. While using grep -n on Date it also gives me the previous line containg Date. and also Date may be DATE in some files. My file is like this... (10 Replies)
Discussion started by: Amiya Rath
10 Replies

2. Shell Programming and Scripting

How to print the words in the same line with space or to the predefined line?

HI, cat test abc echo "def" >> test output is cat test abc def the needed output is cat test abc def and so on (5 Replies)
Discussion started by: jobycxa
5 Replies

3. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

4. UNIX for Dummies Questions & Answers

Trying to sort words and numbers associated with them.

Hi. I have a file containing words and numbers associated with them as follows - c 2 b 5 c 5 b 6 a 10 b 16 c 18 a 19 b 21 c 27 a 28 b 33 a 76 a 115 c 199 c 251 a 567 a 1909 (4 Replies)
Discussion started by: maq
4 Replies

5. UNIX for Dummies Questions & Answers

words sort

hello guys i need a command that take the words from multiple files and put them in another file this way: one word needs to appear only once in the destination file with small letters no matter how it appears in source files , the words from destination file needs to be alphabetical ordered and... (10 Replies)
Discussion started by: G30
10 Replies

6. Shell Programming and Scripting

How can I sort by n number is like words?

I want to sort a file with a list of words, in order of most occuring words to least occurring words as well as alphabetically. ex: file1: cat 3 cat 7 cat 1 dog 3 dog 5 dog 9 dog 1 ape 4 ape 2 I want the outcome to be: file1.sorted: dog 1 (12 Replies)
Discussion started by: castrojc
12 Replies

7. Shell Programming and Scripting

How to sort lines according words?

Hello I greped some lines from an xml file and generated a new file. but some entries are missing my table is unsorted. e.g. NAME="Adel" ADDRESS="Donaustr." NUMBER="2" POSTCODE="33333" NAME="Adel" ADDRESS="Donaustr." NUMBER="2" POSTCODE="33333" NAME="Adel" NUMBER="2" POSTCODE="33333"... (5 Replies)
Discussion started by: witchblade
5 Replies

8. Shell Programming and Scripting

Search words in multiple file line by line

Hi All I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name. (4 Replies)
Discussion started by: netdbaind
4 Replies

9. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies

10. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
atom_application_navigation(5)					File Formats Manual				    atom_application_navigation(5)

NAME
atom_application_navigation, GetFirstObj, GetLastObj, GetNextObj, GetPrevObj, GetFirstObjProc, GetLastObjProc, GetNextProc, GetPrevProc, GetFirstBlock, GetLastBlock, GetNextBlock, GetPrevBlock, GetFirstInst, GetLastInst, GetNextInst, GetPrevInst, GetProcObj, GetBlockProc, GetInstBlock, GetInstBranchTarget - Allows an Atom tool's instrumentation routine to find locations in an application program SYNOPSIS
#include <cmplrs/atom.inst.h> Obj *GetFirstObj( void ); Obj *GetLastObj( void ); Obj *GetNextObj( Obj * ); Obj *GetPrevObj( Obj * ); Proc *GetFirstObjProc( Obj * ); Proc *GetLastObjProc( Obj * ); Proc *GetNextProc( Proc * ); Proc *GetPrevProc( Proc * ); Block *GetFirstBlock( Proc * ); Block *GetLastBlock( Proc * ); Block *GetNextBlock( Block * ); Block *GetPrevBlock( Block * ); Inst *GetFirstInst( Block * ); Inst *GetLastInst( Block * ); Inst *GetNextInst( Inst * ); Inst *GetPrevInst( Inst * ); Inst *GetInstBranchTarget( Inst * ); Obj *GetProcObj( Proc * ); Proc *GetBlockProc( Block * ); Block *GetInstBlock( Inst * ); DESCRIPTION
Atom's application navigation routines allow an instrumentation routine to locate areas of an application that are interesting to monitor or analyze. You can use these routines only from an Atom tool's instrumentation file. See atom(1) for a description of Atom. Atom allows you view an application with the following granularity: The entire application, including all shared libraries. Either the main executable or a shared library. An object comprises a list of procedures and has it own set of attributes (for example, each object has its own name). A procedure. A basic block. An instruction. Note Do not confuse the term object with an object module produced by a compiler. The two terms are completely different. To traverse the list of objects in an application program, use the following routines: Use the GetFirstObj or GetLastObj routine to obtain a pointer to the first or last object in the program. Nonshared programs, have only one object. For call-shared programs, the first object corresponds to the main program and the remaining objects are its shared libraries. Use the GetNextObj routine to obtain a pointer to the object that follows the specified Obj. If the specified Obj is the last object in the program, GetNextObj returns a NULL pointer. Use the GetPrevObj routine to obtain a pointer to the object that precedes the specified Obj. If the specified Obj is the first object in the pro- gram, GetPrevObj returns a NULL pointer. Note Because the Instrument routine is called for each object in the program, the object traversal routines in the Instrument do not need to be used routine. To traverse the list of procedures in an object, use the following routines: Use the GetFirstObjProc or GetLastObjProc routine to obtain a pointer to the first or last procedure in the specified Obj. Use the GetNextProc routine to obtain a pointer to the procedure that follows the specified Proc. If the specified Proc is the last procedure in the object, GetNextProc returns a NULL pointer. Use the GetPrevProc routine to obtain a pointer to the procedure that precedes the specified Proc. If the specified Proc is the first procedure in the object, GetPrevProc returns a NULL pointer. To traverse the list of basic blocks in a procedure, use the following routines: Use the GetFirstBlock or GetLastBlock routine to obtain a pointer to the first or last basic block in the specified Proc. Use the GetNextBlock routine to obtain a pointer to the basic block that follows the specified Block. If the specified Block is the last basic block in the procedure, GetNextBlock returns a NULL pointer. Use the GetPrevBlock routine to obtain a pointer to the basic block that precedes the specified Block. If the specified Block is the first basic block in the procedure, GetPrevBlock returns a NULL pointer. To traverse the instructions in a basic block, use the following routines: Use the GetFirstInst or GetLastInst routine to obtain a pointer to the first or last instruction in the specified Block. Use the GetNextInst routine to obtain a pointer to the instruction that follows the specified Inst. If the specified Inst is the last instruction in the basic block, GetNextInst returns a NULL pointer. Use the Get- PrevInst routine to obtain a pointer to the instruction that precedes the specified Inst. If the specified Inst is the first instruction in the basic block, GetPrevInst returns a NULL pointer. Use the GetInstBranchTarget routine to obtain a pointer to the instruction that is the target of Inst. An error is raised if Inst is not a branch instruction. To navigate between the parts of an application, use the following routines: Use the GetProcObj routine to obtain a pointer to the object that contains the specified Proc. Use the GetBlockProc routine to obtain a pointer to the procedure that contains the specified Block. Use the GetInstBlock routine to obtain a pointer to the basic block that contains the specified Inst. RETURN VALUES
These routines return pointers to Obj, Proc, Block, and Inst structures, or NULL pointers, as described in the preceding section. FILES
Header file containing external definitions of Atom routines SEE ALSO
Commands: atom(1) AtomTools: hiprof(5), pixie(5), third(5) Functions: atom_application_instrumentation(5), atom_application_query(5), atom_application_resolvers(5), atom_description_file(5), atom_object_management(5), atom_instrumentation_routines(5), AnalHeapBase(5), Xlate(5), Thread(5) Programmer's Guide atom_application_navigation(5)
All times are GMT -4. The time now is 11:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy