"sort -k" does not work


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers "sort -k" does not work
# 1  
Old 10-03-2011
"sort -k" does not work

When I issue the following command then the list is NOT sorted starting from column 12:
Code:
find . -maxdepth 1 -type f -printf "%10s ($PWD) /%P\n" |sort -k 12

Why?

I tried this as root in /etc directory.

The output is not sorted with path/filename.

Is piping to sort only applicable to files?

Peter

Last edited by Scott; 10-03-2011 at 07:25 AM.. Reason: Please use code tags
# 2  
Old 10-03-2011
i dont see 12th column of your command output , there are 3 columns so you can sort by file name :
Code:
find . -maxdepth 1 -type f -printf "%10s ($PWD) /%P\n" |sort -k 3

# 3  
Old 10-03-2011
Quote:
Originally Posted by ieth0
i dont see 12th column of your command output , there are 3 columns so you can sort by file name :
Code:
find . -maxdepth 1 -type f -printf "%10s ($PWD) /%P\n" |sort -k 3

Ok, I though sort -k <n> will start at the n-th character in a line

Thank you
Peter
# 4  
Old 10-04-2011
What is the difference between the format specifier "%P" and "%f" in printf function of find command? Because both are printing the file name without absolute path.
# 5  
Old 10-04-2011
Check out on linux box
Code:
info coreutils 'printf invocation'

I believe you should open new topics for new questions

Regards
Peasant.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

7. OS X (Apple)

Neither "which" nor "find" commands work

hi there, could use some basic PATH advice, i think, or something find sometimes work, but which hasn't ever seemed to. for years! what am i doing wrong that the commands which and find rarely work? they used to work on the workstations i used ages ago... running 10.5.8 because i... (4 Replies)
Discussion started by: zensnob
4 Replies
Login or Register to Ask a Question