How to remove filenames having the same extension.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove filenames having the same extension.?
# 8  
Old 08-07-2013
Quote:
Originally Posted by itkamaraj
Code:
$ awk -F\. '!a[$NF]++'

Your simple code could even have an easy variation as well. Simply removing ! would print those that are to be excluded instead. This is useful if they are to be deleted.
Code:
awk -F. 'a[$NF]++' a.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash to remove find and remove specific extension

The bash below executes and does find all the .bam files in each R_2019 folder. However set -x shows that the .bam extension only gets removed from one .bam file in each folder (appears to be the last in each). Why is it not removing the extension from each (this is $SAMPLE)? Thank you :). set... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Remove extension in loop

Dear all sorry for bothering you wityh dumb question but I am stucked with an issue. Well, I am trying to loop over files in folder, make an operation and rewrite the output. Example: INPUT file1.txt file2.txt file3.txtMy command (doesn't work!!) for file in /path/to/*.txt do command... (13 Replies)
Discussion started by: giuliangiuseppe
13 Replies

3. Shell Programming and Scripting

Remove the file except with particular extension

Hi all i am new for the shell scripting can any one help me with my requirments . i want to delete file older than 21 days everything works fine but in that dir i got the files with should not be deleted with particular extension like (.info):confused:here is the script i wrote .can anyone... (5 Replies)
Discussion started by: vikatakavi
5 Replies

4. Shell Programming and Scripting

Remove spaces in filenames

Hi, I have files like below, In files coming as spaces. Before transfering those files into ftp server. I want to remove the spaces and then can transfer the files into unix server. e.g: filenames are 1) SHmail _profile001_20120908.txt 2) SHmail_profile001 _20120908.txt 3) sh... (3 Replies)
Discussion started by: kirankumar
3 Replies

5. Shell Programming and Scripting

change filenames but not extension

I have a filename with a bunch of periods that I want to replace with underscores, but I don't want to change the extension. Ex: I want file.test1.f-1.fig.eps to be file_test1_f-1_fig.eps Using awk, the following line will replace ALL periods with underscores, but I want to leave the... (2 Replies)
Discussion started by: erinbot
2 Replies

6. UNIX for Dummies Questions & Answers

removing the extension from all filenames in a folder

Hi there, I'm pretty new to UNIX and have tried trawling through this forum to find an answer to what I want to try to do, which I'm sure is very simple but I don't know how to do it. What I have a a folder that contains multiple files that I have copied from Windows and I want to remove the... (5 Replies)
Discussion started by: johnmcclintock
5 Replies

7. Shell Programming and Scripting

Reading filenames with extension .xml

Hi, I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function. Please help me out. Regards. Saurabh (3 Replies)
Discussion started by: bhalotias
3 Replies

8. Shell Programming and Scripting

remove file extension

Hi ALL, I'm new to this forum. Thanks and congrats to all for their great efforts building this site simply superb for all unix administrators. My requirement is to remove extensions of the files in the current directory. I'm doing it using below script which is working but i think it is... (12 Replies)
Discussion started by: prvnrk
12 Replies

9. Shell Programming and Scripting

Remove prefix from filenames

I'm trying to put together a shell script that will append specific prefixes based on the content of filenames. I think I have this part down. However, I want to append before that part a process that will remove the current prefix before it renames the files with the new prefix. For example,... (6 Replies)
Discussion started by: HLee1981
6 Replies

10. UNIX for Dummies Questions & Answers

Adding an extension to a group of filenames

Hi - I'm stuck. I have a group of text files created using the split command. My files have the names "projectaa", "projectab", "projectac", etc. What I want to do is add the extension ".txt" to each file. I think I've got part of a sed command together, but I'm stuck on my regex - I keep getting... (9 Replies)
Discussion started by: pepintheshort
9 Replies
Login or Register to Ask a Question
MKMANIFEST(1)						      General Commands Manual						     MKMANIFEST(1)

NAME
mkmanifest - create a shell script to restore Unix filenames SYNOPSIS
mkmanifest [ files ] DESCRIPTION
Mkmanifest creates a shell script that will aid in the restoration of Unix filenames that got clobbered by the MSDOS filename restrictions. MSDOS filenames are restricted to 8 character names, 3 character extensions, upper case only, no device names, and no illegal characters. The mkmanifest program is compatible with the methods used in pcomm, arc, and mtools to change perfectly good Unix filenames to fit the MSDOS restrictions. EXAMPLE
I want to copy the following Unix files to a MSDOS diskette (using the mcopy command). very_long_name 2.many.dots illegal: good.c prn.dev Capital Mcopy will convert the names to: very_lon 2xmany.dot illegalx good.c xprn.dev capital The command: mkmanifest very_long_name 2.many.dots illegal: good.c prn.dev Capital > manifest would produce the following: mv very_lon very_long_name mv 2xmany.dot 2.many.dots mv illegalx illegal: mv xprn.dev prn.dev mv capital Capital Notice that "good.c" did not require any conversion, so it did not appear in the output. Suppose I've copied these files from the diskette to another Unix system, and I now want the files back to their original names. If the file "manifest" (the output captured above) was sent along with those files, it could be used to convert the filenames. SEE ALSO
arc(1), pcomm(1), mtools(1) local MKMANIFEST(1)