Unix/Linux Go Back    


Debian Debian GNU/Linux is a free distribution of the GNU/Linux operating system.

Changing file extension names

Debian


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
anaigini45 anaigini45 is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 21 July 2017, 6:02 AM EDT
Posts: 84
Thanks: 4
Thanked 0 Times in 0 Posts
Changing file extension names

Hi I have a list of files :
Code:
root@L28mustang:/var/log/exim4/2017/Jul2017_Blast_BC07# ls -lrt | grep mainlog
-rw-r----- 1 Debian-exim adm  3636932 Jul  8 06:25 mainlog.3.gz
-rw-r----- 1 Debian-exim adm   919512 Jul  9 06:27 mainlog.2.gz
-rw-r----- 1 Debian-exim adm  7655054 Jul 10 06:25 mainlog.1
-rw-r----- 1 Debian-exim adm  2799218 Jul 10 15:40 mainlog

I need to change the extension names for all the files above to .filtered.
I know how to do it for the .gz files like this :


Code:
for i in mainlog*
	do
	   exigrep L28stream1 "$i" | egrep -v "jiun.shyong.hor@ericsson.com|chander.c.shekher@ericsson.com|nagios|L28eagle" > "${i/%.gz/.filtered}"
done

How do I change both the mainlog files with the .gz extension and without the .gz extension in one command?

Last edited by rbatte1; 1 Week Ago at 11:33 AM.. Reason: Code tags
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 24 July 2017, 8:51 PM EDT
Location: Simplicity
Posts: 3,637
Thanks: 285
Thanked 1,217 Times in 1,100 Posts
Strip a .gz and add .filtered

Code:
... > "${i%.gz}.filtered"

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing file names kristinu Shell Programming and Scripting 3 04-01-2014 01:11 PM
Changing file extension in csh alias ygmwayne Shell Programming and Scripting 1 09-28-2012 03:41 AM
Changing file extension jaysean UNIX for Dummies Questions & Answers 4 07-16-2010 03:31 AM
changing file extension spidydude UNIX for Dummies Questions & Answers 6 02-17-2009 02:21 AM
Changing the extension of the file mazhar803 UNIX for Dummies Questions & Answers 4 08-29-2008 09:20 AM



All times are GMT -4. The time now is 02:41 AM.