Sponsored Content
Top Forums Shell Programming and Scripting Sort a file content using one column Post 302895834 by kumar30213 on Wednesday 2nd of April 2014 06:07:02 PM
Old 04-02-2014
RedHat Sort a file content using one column

Hello All,
I have a file which have content as below.
Code:
03/09/2014  10:35 AM  618 Admin\rick        pqr_ klm2_pog12_20140309_c.xlsx
03/10/2014  10:35 AM  618 user\test01      mplz_ fgh2_lal12_20140310_c.xlsx
03/17/2014  10:35 AM  618 Admin\vick        abc_ xyz2_bc12_20140317_c.xlsx
03/18/2014  10:35 AM  618 admin1\rick       abc_ pqr2_dq12_20140318_c.xlsx
03/19/2014  10:35 AM  618 Admin\mike       abc_ xyz2_bc12_20140319_c.xlsx
03/31/2014  10:35 AM  618 Admin\vick        abc_ xyz2_bc12_20140317_c.xlsx

I want to sort this file using Last column and remove the duplicate. I can remove duplicate value. but i think it is removing new value and not the old value.

Code:
awk '!a[$6]++'

if i remove duplicate using above awk statement i get below output.
Code:
03/09/2014  10:35 AM  618 Admin\rick        pqr_ klm2_pog12_20140309_c.xlsx
03/10/2014  10:35 AM  618 user\test01      mplz_ fgh2_lal12_20140310_c.xlsx
03/17/2014  10:35 AM  618 Admin\vick        abc_ xyz2_bc12_20140317_c.xlsx
03/18/2014  10:35 AM  618 admin1\rick       abc_ pqr2_dq12_20140318_c.xlsx
03/19/2014  10:35 AM  618 Admin\mike       abc_ xyz2_bc12_20140319_c.xlsx

where as i want output as below

Code:
03/09/2014  10:35 AM  618 Admin\rick        pqr_ klm2_pog12_20140309_c.xlsx
03/10/2014  10:35 AM  618 user\test01      mplz_ fgh2_lal12_20140310_c.xlsx
03/18/2014  10:35 AM  618 admin1\rick       abc_ pqr2_dq12_20140318_c.xlsx
03/19/2014  10:35 AM  618 Admin\mike       abc_ xyz2_bc12_20140319_c.xlsx
03/31/2014  10:35 AM  618 Admin\vick        abc_ xyz2_bc12_20140317_c.xlsx

can someone please help me to solve this.

Thanks

Last edited by kumar30213; 04-02-2014 at 08:02 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort a particular column in a file

Dear All, Good day. Here i am facing some problem like below. file contains 12345 0001 090112 14385 0001 090112 13255 0001 090112 11345 0001 090112 .... I want to sort ascending according to the first column. What will be the shell script. (4 Replies)
Discussion started by: saifurshaon
4 Replies

2. Shell Programming and Scripting

Sort file based on column

Hi, My input file is $cat samp 1 siva 1 raja 2 siva 1 siva 2 raja 4 venkat i want sort this name wise...alos need to remove duplicate lines. i am using cat samp|awk '{print $2,$1}'|sort -u it showing raja 1 (3 Replies)
Discussion started by: rsivasan
3 Replies

3. Shell Programming and Scripting

Can't sort file by size column

Hello, I've done ls -ls >fileout1 When I do the sort command for +4 it sorts it bu group. When I do +5 it sorts it by date. But it's skipping the file size column. Example: rwxr-xr-x 1 Grueben sup 65 16 Sep 13:58 cdee How can I sort it by file size? It doesn't... (2 Replies)
Discussion started by: Grueben
2 Replies

4. Shell Programming and Scripting

Sort content of text file based on date?

I now have a 230,000+ lines long text file formatted in segments like this: Is there a way to sort this file to have everything in chronological order, based on the date and time in the text? In this example, I would like the result to be: (19 Replies)
Discussion started by: KidCactus
19 Replies

5. Shell Programming and Scripting

sort each column of text file alone

Hello , i have a text file like this 1 a1 ,AB ,AC ;AD ,EE 2 a2 ,WE ;TR ,YT ,WW 3 a3 ;AS ,UY ;RF ,YT i want to sort this text file based on each row , and excluding 2nd column from the sorting and not taking the comma or ; into consideration in the sorting, so it will become like this... (12 Replies)
Discussion started by: shelladdict
12 Replies

6. Shell Programming and Scripting

Change file content 4 column to one Column using script

Hi Gurus, I have file content sample: ,5113955056,,TAgent-Suspend ,5119418233,,TAgent-Suspend ,5102119078,,TAgent-Suspend filenames 120229H5_suspend, 120229H6_unsuspend I receive those files one of directory /home/temp/ I need following: 1. Backup first /home/temp/ file to... (5 Replies)
Discussion started by: thepurple
5 Replies

7. Shell Programming and Scripting

Adding content of two file in a single file column wise

Hi, I am trying to get the file in particular pattern using shell script. I have to add one column to some other file. For example consider two file as below. File1: name1 name2 name3 File2: Add1 age1 Add2 age2 Add3 age3 I want this two file in a single file format something like... (3 Replies)
Discussion started by: diehard
3 Replies

8. Shell Programming and Scripting

Sort a file content with space

Hello, I need help on. I have a File which stores the information as below. It is space separated file, I want to keep only unique record in file based on file name. Also if you notice sometime filename with space appear in last column like (abc_ xyz1_bc12_20140312_c.xlsx) 03/17/2014 ... (9 Replies)
Discussion started by: kumar30213
9 Replies

9. UNIX for Dummies Questions & Answers

How to sort a content of a text file using a shell script?

I am new to shell scripting. I am interested how to know how to sort a content of a file using shell scripting. I've attached the 'Input file' and the 'expected output' to this thread. Details provided in the expected output file will provide details on how the sort needs to be done. ... (16 Replies)
Discussion started by: nkarthik_mnnit
16 Replies

10. Shell Programming and Scripting

How to Modify a file content in UNIX and sort for only required fields ?

I have the below contents in a file after making the below curl call curl ... | grep -E "state|Rno" | paste -sd',\n' | grep "Disconnected" > test "state" : "Disconnected",, "Rno" : "5554f1d2" "state" : "Disconnected",, "Rno" : "10587563" "state" : "Disconnected",, "Rno" :... (2 Replies)
Discussion started by: Vaibhav H
2 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. --font=desc Set the font description. Default is Monospace 12. --rtl Do rtl layout. --paper ps Choose paper size. Known paper sizes are legal, letter, a4. Default is A4. --bottom-margin=bm Set bottom margin in postscript points (1/72 inch). Default is 36. --top-margin=tm Set top margin. Default is 36. --left-margin=lm Set left margin. Default is 36. --right-margin=rm Set right margin. Default is 36. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --encoding=ENCODING Assume the documentation encoding is ENCODING. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy