string sorting in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting string sorting in unix
# 1  
Old 09-24-2011
string sorting in unix

Hi I need how to sort string characters

for Example i have a file that contains this data
example string "fan" but i want to display "afn" contained words
"afn" is in sorted format for fan.

File data
Code:
faty
gafny
gaifny
dafan
gafnniunt

O/p
Code:
gafny
gafnniunt

# 2  
Old 09-25-2011
grep afn filename
# 3  
Old 09-25-2011
Hey i know that grep afn filename.

but we dont know that afn is the string to be search..

if "hate" is the string then we need to search for "aeht"
if "hat" is the string then we need to search for "aht"

we need to search like this. please with the good answer
# 4  
Old 09-25-2011
What have you tried to solve this problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sorting in UNIX

hi experts, I have a flat file with 2 fields, 1st field is alpha-numeric and 2nd is numeric. Input file is :: A_0 11 A_0 12 A_0 13 C_0 3 B_1 21 B_1 22 A_0 1 A_0 2 I want to sort this file, first based on 1st field, then on 2nd field Output should be :: A_0 1 A_0 2 A_0 11... (1 Reply)
Discussion started by: sandeepkmehra
1 Replies

2. Shell Programming and Scripting

[Perl] Sorting an String-Array

Hi, i have a txtfile with the format <Nr>tab<word>tab<other stuff>new line and i want to sort the <word>-colum with a perl script. My textfile: <Nr>tab<word>tab<other stuff>new line 6807 die ART.Acc.Sg.Fem 6426 der ART.Gen.Sg.Fem 2 die ART.Nom.Sg.Fem 87 auf APPR.-- 486 nicht PTKNEG.--... (1 Reply)
Discussion started by: buckelede
1 Replies

3. Shell Programming and Scripting

Sorting string with date and number

Hi, We have files coming in the system and we want to sort it in ascending order with date and sequence. The file pattern are inbound_crp_date_sequence.xml example we have file as below: inbound_crp_20100422_10.xml inbound_crp_20100422_2.xml inbound_crp_20100422_3.xml... (2 Replies)
Discussion started by: sreejitnair123
2 Replies

4. UNIX for Advanced & Expert Users

Need help for sorting in Unix

Hi I have a query regarding syncsort in Unix. What is the difference between Syncsort and normal sort. If I have 4 columns to do sort in a csv file and and first col, and third col to be done in descending order. How can I do that in Unix/ Please help me..Its urgent. (3 Replies)
Discussion started by: srinu19
3 Replies

5. UNIX for Dummies Questions & Answers

Sorting in Unix

Hi I'm writing a shell that goes through a bunch of files and does a simple test on each. Each file has a numeric name (ex. 100.jpg). My problem is that the shell is going through the files in alphabetical rather than numeric order. Thus, after checking file 19.jpg it skips to 100.jpg. Once... (7 Replies)
Discussion started by: Bengel
7 Replies

6. Shell Programming and Scripting

unix sorting

Hi experts, i have a file.If i will delete some intermediate records from the file then the output file will be in sorted format as show below. file A ==== D001 ty gh D002 fg hi D003 jk lr . . . if i will delete the 2nd record then the output file is as follows: outputfile:... (1 Reply)
Discussion started by: subhendu81
1 Replies

7. UNIX for Dummies Questions & Answers

sorting ASCII string containing numbers

I have the following output where I need to sort the second column numerically (starting with IBMULT3580-TD10 and ending in IBMULT3580-TD123) Drv DriveName 0 IBMULT3580-TD13 1 IBMULT3580-TD18 2 IBMULT3580-TD14 3 IBMULT3580-TD10 4 IBMULT3580-TD11 5 IBMULT3580-TD17 ... (8 Replies)
Discussion started by: GKnight
8 Replies

8. Shell Programming and Scripting

Perl: sorting by string

I have an array full of string values that need to be sorted, but if a value starts with (regex) 0^ it should be at the beginning of the array. Otherwise the array should be sorted normally using ascii sort. Please help me create the sub to pass to the sort function. (7 Replies)
Discussion started by: dangral
7 Replies

9. Shell Programming and Scripting

Sorting an address string

I'm in an introduction to Unix class and well I'm kind of stuck on one part of the lab for this week or shell scripts. Basically we're given a file named address.data and we're supposed to create a script to sort it according to zip code, last name, and first name (not at the same time of course).... (0 Replies)
Discussion started by: Minimum
0 Replies

10. UNIX for Advanced & Expert Users

Sorting a string

Hello all, I have some 20-digit strings - say 1234567890abcdefghij I want to remove the 3rd and then the 11-18th strings, but leave a space between the two resulting strings eg "3 abcdefgh" I only know how to use "cut", does anyone know any way I can do this? All these strings are in the same... (14 Replies)
Discussion started by: Khoomfire
14 Replies
Login or Register to Ask a Question