sorting names after doing a find


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sorting names after doing a find
# 1  
Old 10-16-2008
sorting names after doing a find

hi all,
is there an easy way in ksh to sort the results of a find in say alphabetical order ?? e.g in my script i am doing a find for all servers

find . -name "server.xml"

and the output is not in any order.


thanks in advance.
# 2  
Old 10-17-2008
sorry forgot to mention the output currently looks like :

myServerA
myServerB
.
.
myServerN
myServerNew1
myServerNew2
.
.
myServerNew6
myServerO
myServerP





desired output would be :


myServerA
myServerB
.
.
myServerN
myServerO
myServerP
.
.
myServerNew1
myServerNew2
.
.
myServerNew6
# 3  
Old 10-17-2008
try this..
hope it will work
Code:
sort -k 1.11 filename

# 4  
Old 10-17-2008
Quote:
Originally Posted by vidyadhar85
try this..
hope it will work
Code:
sort -k 1.11 filename

Neat trick! *makes mental note*
# 5  
Old 10-17-2008
Check this

$ cat filename
myServerA
myServerB
myServerN
myServerNew1
myServerNew2
myServerNew6
myServerO
myServerP

$ awk '{print length,$0}' filename|sort -n|cut -d' ' -f2-
myServerA
myServerB
myServerN
myServerO
myServerP
myServerNew1
myServerNew2
myServerNew6
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting a column according to the number of names

Hey, So I'm having issues sorting a data set. The data set contains entries as such; # key: sex, time, athlete, athlete's nationality, date, city, country M, 2:30:57.6, Harry Payne, GBR, 1929-07-05, Stamford Bridge, England M, 2:5:42, Khalid Khannouchi, MAR, 1999-10-24, Chicago, USA M,... (1 Reply)
Discussion started by: DNM_UKN
1 Replies

2. Shell Programming and Scripting

sorting file names with hyphen and underscore

Hi, I have two types of file names filename1_12345 or filename1-12345 at the same time I have second type filename2-12345 in a txt file. I am trying to write awk script that will sort these names with below pattern ALL file names like filename1_12345 and filename1-12345 will go to... (1 Reply)
Discussion started by: rider29
1 Replies

3. Shell Programming and Scripting

How to find files without any name i.e. blank names???

I tried using find . -type f -name " " It works only if there is single space. what if i want to find only for the files without any name(no space constraint)??? (12 Replies)
Discussion started by: nikhil jain
12 Replies

4. Shell Programming and Scripting

Sorting file based on names

Hi I have some files in directory and the names of files are like jnhld_15233_2010-11-23 jnhld_15233_2007-10-01 jnhld_15233_2001-05-04 jnhld_15233_2011-11-11 jnhld_15233_2005-06-07 jnhld_15233_2000-04-01 ..etc How can i sort these files based on the date in the file name so that ... (4 Replies)
Discussion started by: morbid_angel
4 Replies

5. Shell Programming and Scripting

faster command than find for sorting?

I'm sorting files from a source directory by size into 4 categories then copying them into 4 corresponding folders, just wondering if there's a faster/better/more_elegant way to do this: find /home/user/sourcefiles -type f -size -400000k -exec /bin/cp -uv {} /home/user/medfiles/ \; find... (0 Replies)
Discussion started by: unclecameron
0 Replies

6. Shell Programming and Scripting

please help, find domain names in string

Hello, i have a file contains the information like below /home/username/domain.com/log/access /home/username/domain23.net/log/access /home/reseller/username/domain.com/log/access using a loop i can read every line of the file but i wants to extract domain name like(domain.com,... (3 Replies)
Discussion started by: eyes_drinker
3 Replies

7. Shell Programming and Scripting

script to find function names

hi, i am a newbie and have to write a rather complicated script. Assume that i have a variable called x and a C source code file say file1.c (these are the inputs of the script) and i need to find the names of all the functions in the C file containing x.Take the following code as an example: ... (2 Replies)
Discussion started by: samantha grace
2 Replies

8. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

9. UNIX for Advanced & Expert Users

Find File names with sustitution

Hi All, Iam trying to find two kinds of files while ignoring rest of the files in a directory The files are like below Files to be found -------------------- perp45560 oerp4556 Files to be ignored ---------------------- oerp4556123450 oerp4556123470 I was trying the following... (4 Replies)
Discussion started by: baanprog
4 Replies

10. IP Networking

find computer names from IP addresses?

Arright, here's what I'm trying to do. I want to dig up currently active IP addresses on my subnet, and my present strategy is to ping every address until I find active ones, then ping them more often to verify their status. Next, I want to find the names of the computers associated with those... (1 Reply)
Discussion started by: sladuuch
1 Replies
Login or Register to Ask a Question