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
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 03:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy