LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2016, 04:35 AM   #1
llee4131
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Rep: Reputation: 0
sort command doesn't work as expected


See here
http://pastebin.com/sK2MDW5f

I want to sort by second letter of the second field.
Help
 
Old 04-25-2016, 04:47 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Then you should specify your parms correctly. See the manpage.
 
Old 04-25-2016, 05:27 AM   #3
llee4131
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Original Poster
Rep: Reputation: 0
This works

root@kali:~/tests/awk_tests/25_april_2016/sort_commd# sort -k 1.5 < txt_samp
02 Marie Jr.Developer
04 Dave Sr.Developer
03 Albert Jr.Designer
01 Joe Sr.Designer
 
Old 04-25-2016, 05:38 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by llee4131 View Post
I want to sort by second letter of the second field.
Help
In which case, how do you explain your use of "-k 2.1" ?.

Read the manpage.
 
1 members found this post helpful.
Old 04-25-2016, 05:43 AM   #5
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Never mind...

Last edited by HMW; 04-25-2016 at 06:00 AM.
 
Old 04-25-2016, 07:43 AM   #6
kiyop
Member
 
Registered: Jun 2015
Distribution: Debian, Arch
Posts: 56

Rep: Reputation: Disabled
Talking

Quote:
Originally Posted by llee4131 View Post
This works

root@kali:~/tests/awk_tests/25_april_2016/sort_commd# sort -k 1.5 < txt_samp
You are too optimistic.
Code:
$ cat test
z1119 93
y1118 15
b1117 34
c1116 67
$ sort -k 1.5 test
c1116 67
b1117 34
y1118 15
z1119 93
Read manual of sort.

2.3 or 2.2

Last edited by kiyop; 04-25-2016 at 07:53 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] keyboard doesn't work as expected hua Solaris / OpenSolaris 13 06-03-2013 07:56 AM
iptables doesn't work as expected rluo Red Hat 3 01-18-2013 12:34 AM
Subwoofer doesn't work as expected Kubuntu Linux - Hardware 0 06-20-2012 03:23 PM
Crond script doesn't work as expected Karimo Slackware 1 02-14-2010 06:32 PM
iptables rules doesn't work as expected.. Shioni Linux - Security 4 11-15-2006 01:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:22 PM.

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