Computing.Net > Forums > Unix > Listing the file group by type

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Listing the file group by type

Reply to Message Icon

Name: psiva_unix
Date: April 16, 2009 at 04:42:50 Pacific
OS: Windows XP
CPU/Ram: -
Product: Sun / --
Subcategory: Software Problems
Comment:

Hi all,

i want to listing the file group by file extenstion (type)
i have 4 .csh and 2 .txt and 3 csv file in my current dirm i want to know only the type of file extenstion like this
csh
txt
csv

i tired one command but its listing all file type. not listing uniq records
$ ls -rtl | awk '{ print $8 }' | awk -F"." '{print $NF}' | uniq -u

pls help on this.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 16, 2009 at 06:24:36 Pacific
Reply:

I think you have your field count wrong and you probably do not want the -u flag on uniq:


ls -rtl | awk '{ print $9 }' | awk -F"." '{print $NF}' | uniq

But I don't see why you need to do a long listing:

ls -rt1 | awk -F"." '{print $NF}' | uniq

Above, that is a "1" - not an "l"


0

Response Number 2
Name: psiva_unix
Date: April 16, 2009 at 06:38:19 Pacific
Reply:

Nail, the above command is working but it returning duplicate values also

Let me take my example:

my folder has totally 38 files, in that
28 perl files and 10 txt file are there

If i execute your command its returning

pl
txt
pl
txt
pl
txt

But i want the output like this
pl
txt

Thanks


0

Response Number 3
Name: psiva_unix
Date: April 16, 2009 at 06:43:34 Pacific
Reply:

Thanks Nails, i tried your command with sort command
its working, see the below command and output

$ ls -rt1 | awk -F"." '{print $NF}' | sort | uniq

output:

pl
txt

Thanks


0

Response Number 4
Name: nails
Date: April 16, 2009 at 07:14:26 Pacific
Reply:

<deleted>


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Listing the file group by type

grep only on files owned by bob www.computing.net/answers/unix/grep-only-on-files-owned-by-bob/3125.html

Shell script to get the files by range www.computing.net/answers/unix/shell-script-to-get-the-files-by-range/8413.html

How to create listing shell script www.computing.net/answers/unix/how-to-create-listing-shell-script-/6209.html