Urgent help on sorting


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Urgent help on sorting
# 1  
Old 04-25-2019
Urgent help on sorting

Hello Everyone, I need urgent help here . I need to sort a file for one of my requirement , The file has to be sorted using a key with 4 columns. Sorting is working fine on those 4 columns but when the key is matching for many rows the other columns are also getting sorted which is not required .

Giving an example here : File = Input.txt
1 101 100
1 001 200
1 002 100

Here I am using below command to sort.

Sort -k1,1 -k3 Input.txt

This gives me below output:
1 002 100
1 101 100
1 001 200

I don't want to sort the second column here . I have tried with -s option for stable sort but the same is not supported .

Please help.
# 2  
Old 04-25-2019
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help on Sorting

Hello Everyone, I need help here . I need to sort a file for one of my requirement , The file has to be sorted using a key with 4 columns. Sorting is working fine on those 4 columns but when the key is matching for many rows the other columns are also getting sorted which is not required . ... (11 Replies)
Discussion started by: richa_240889
11 Replies

2. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

3. Shell Programming and Scripting

Urgent ...pls Sorting files based on timestamp and picking the latest file

Hi Friends, Newbie to shell scripting. Currently i have used the below to sort data based on filenames and datestamp $ printf '%s\n' *.dat* | sort -t. -k3,4 filename_1.dat.20120430.Z filename_2.dat.20120430.Z filename_3.dat.20120430.Z filename_1.dat.20120501.Z filename_2.dat.20120501.Z... (1 Reply)
Discussion started by: robertbrown624
1 Replies

4. UNIX for Dummies Questions & Answers

Help sorting with du

Hi! As a part of a larger script I'm using the comand du -k to get the sizes of various directories, the output is printed like this: 1324 ./images/backup/2012 1333 ./images/backup 1400 ./images 22 ./video/backup 44 ./video 1450 . I'm trying to print it the other way around with... (2 Replies)
Discussion started by: Tralaraloro
2 Replies

5. UNIX for Advanced & Expert Users

HELP on sorting

hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this; 192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible... (1 Reply)
Discussion started by: sam127
1 Replies

6. Shell Programming and Scripting

Sorting

Let's say that I have a database that I call part ID. This database has the following grouping: Dart1=4 Dart2=8 Dart3=12 Fork1=68 Fork2=72 Fork3=64 Bike1=28 Bike2=24 Bike3=20 Car1=44 Car2=40 Car3=36 I want to write a program that would read this database and tell me when the... (19 Replies)
Discussion started by: Ernst
19 Replies

7. Shell Programming and Scripting

Regarding sorting

I have the following file. Its an output from a du command with certain conditions attached to it. I used du -ah as I need the 1st column to look human readable. sort -nr is not giving me the output I need, nor is sort -dr. Please help out. cat testout 121K ./OMautomation/pvd 14M ... (6 Replies)
Discussion started by: vivek.bharadwaj
6 Replies

8. UNIX for Advanced & Expert Users

URGENT,URGENT- Need help tape drive installation

Hi, I am trying to attach tape drive to sun V890 running Solaris 9 on it. I have installed HBA(qlogic) in slot 1 of 0-8 slots and booted the system. I do not see HBAin prtdiag output. The tape drive is not attached to HBA. The tape drive I am going to attach is Sony AIT3. 1.How can I make... (3 Replies)
Discussion started by: sriny
3 Replies

9. Shell Programming and Scripting

Need Urgent help in Sorting

This is what i have in a file sortdata IGOT C9.1.20.2DBSU10 - - CVGRETesting C9.1.20.2DBSU11 - - BalInqMail C9.1.20.2DBSU11 - - SecScore C9.1.20.2DBSU8 - - IGOT C9.1.20.2DBSU8 - - IGOT C9.1.20.2DBSU9 - - SecScore C9.1.20.2DBSU9 - - When i Sort i am getting BalInqMail... (4 Replies)
Discussion started by: pulluru
4 Replies
Login or Register to Ask a Question