Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need to modify a delimited file using UNIX commands. Please find description Post 302783823 by ankurgoyal2408 on Thursday 21st of March 2013 04:10:50 AM
Old 03-21-2013
Need to modify a delimited file using UNIX commands. Please find description

i have a '|' delimited file having 4 fields.
now i want to sort the data by combination of first three fields without changing order of 4th field.
input file looks like this:

Code:
3245|G|kop|45
1329|A|uty|76
9878|K|wer|12
3245|G|kop|15
1329|A|uty|56
9878|K|wer|2
3245|G|kop|105
1329|A|uty|506
9878|K|wer|20
3245|B|aop|15
1329|M|aty|56
9878|J|aer|2

now i want to have some modification of sorting that output file shoul look like:

Code:
3245|G|kop|45
3245|G|kop|15
3245|G|kop|105
1329|A|uty|76
1329|A|uty|56
1329|A|uty|506
9878|K|wer|12
9878|K|wer|2
9878|K|wer|20
3245|B|aop|15
1329|M|aty|56
9878|J|aer|2

Please Help. i am not getting desired output after many tries.

Last edited by Scrutinizer; 03-21-2013 at 05:41 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies

2. UNIX for Dummies Questions & Answers

Unix Find commands

thank you for the help (1 Reply)
Discussion started by: scooter17
1 Replies

3. UNIX for Advanced & Expert Users

How to modify an existing pdf with unix shell commands

Hi, I know that to create a pdf file I can use the txt2pdf command. But if I would change an existing pdf file, by inserting lines in particular positions of this file, what can I use? And How? (3 Replies)
Discussion started by: fandwick
3 Replies

4. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

5. UNIX for Dummies Questions & Answers

Please help me to find the functions for description

i have taken a screen shot of the question. http://www.magicscreenshot.com/MagicScreenshot/REAdbT956kE.png Please some one help me.:) (1 Reply)
Discussion started by: kjamsheed
1 Replies

6. UNIX for Advanced & Expert Users

I need help to find some unix commands

Hey everyone, I need some help for some unix commands. - List all processes in the file "ProcessUser.txt" sorted by the users and in the file "ProcessName.txt" sorted by the name of the process. - How much time does the command "ls -alR /" need and compared to that, how much time is... (2 Replies)
Discussion started by: ZOCKER3000
2 Replies

7. Programming

Where to find sources of UNIX commands???

Dear friends, I believe that all unix commands are programs which are written in c language, please correct me if I am wrong. Now suppose that I want to see the c source of common commands like echo, ls, mkdir etc, where I can I find the source, linux is open source I believe, so the source for... (2 Replies)
Discussion started by: gabam
2 Replies

8. Shell Programming and Scripting

Help me to find a solution using UNIX commands

I have the below requirement. below is the content of the input file and my expected result Input file: a.txt <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>XXXX</Name> <ID>1233</ID> </Employee> <?xml version="1.0" encoding="UTF-8"?> <Employee> <Name>YYYY</Name> <ID>1345</ID>... (2 Replies)
Discussion started by: kmanivan82
2 Replies

9. Shell Programming and Scripting

Modify comma delimited file columns.

Please help me to update a file which contains date values as below:- From:- "1912108",20161130,"2016-12-01-00.00.00.000000","2016-12-01-08.37.12.000000" "1912108",20161201,"2016-12-02-00.00.00.000000","2016-12-02-08.28.22.000000" To:- "1912108",2016-11-30,"2016-12-01... (7 Replies)
Discussion started by: KrishnaVM
7 Replies

10. Shell Programming and Scripting

Find and modify a huge file

Dear Forum, I have a rather large file with a few million lines looking like this: head -n 5 seq.txt >KF1.8.1 010011001011100010101110000000 >DF1.6.1 0101000010111010101011111100 >XC1.3.7 010110101011101010110000011 >GG5.1.1 0100011010111010101110001101 >HK1.2.2... (5 Replies)
Discussion started by: GDC
5 Replies
SORT(1) 						      General Commands Manual							   SORT(1)

NAME
sort - sort a file of ASCII lines SYNOPSIS
sort [-bcdfimnru] [-tc] [-o name] [+pos1] [-pos2] file ... OPTIONS
-b Skip leading blanks when making comparisons -c Check to see if a file is sorted -d Dictionary order: ignore punctuation -f Fold upper case onto lower case -i Ignore nonASCII characters -m Merge presorted files -n Numeric sort order -o Next argument is output file -r Reverse the sort order -t Following character is field separator -u Unique mode (delete duplicate lines) EXAMPLES
sort -nr file # Sort keys numerically, reversed sort +2 -4 file # Sort using fields 2 and 3 as key sort +2 -t: -o out # Field separator is : sort +.3 -.6 # Characters 3 through 5 form the key DESCRIPTION
Sort sorts one or more files. If no files are specified, stdin is sorted. Output is written on standard output, unless -o is specified. The options +pos1 -pos2 use only fields pos1 up to but not including pos2 as the sort key, where a field is a string of characters delim- ited by spaces and tabs, unless a different field delimiter is specified with -t. Both pos1 and pos2 have the form m.n where m tells the number of fields and n tells the number of characters. Either m or n may be omitted. SEE ALSO
comm(1), grep(1), uniq(1). SORT(1)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy