Sponsored Content
Operating Systems Linux Debian Changing file extension names Post 303000637 by anaigini45 on Monday 17th of July 2017 02:09:17 AM
Old 07-17-2017
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; 07-17-2017 at 12:33 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

changing file names to lowercase

hey guys having some trouble figuring this out. my program is supposed to take a name of a directory as a command line argument and change the filenames inside that directory to lowercase. what i dont get is how you access that directory and go thru all the files and change the filenames... (1 Reply)
Discussion started by: 30177005
1 Replies

2. UNIX for Dummies Questions & Answers

Changing the extension of the file

I have a list of files in a particular folder Example: File name - sample.F1.test I want to change the extension of the above file to .csv The final file should be renamed as sample.csv (4 Replies)
Discussion started by: mazhar803
4 Replies

3. UNIX for Dummies Questions & Answers

changing file extension

Hello, everyone! :] I'm having an issue with my camera/uploading to Photobucket. When my camera transfers it's photos to my hard drive, it transfers them as .JPG. Unfortunately, when I go to upload to my Photobucket account, it only accepts .jpg & .jpeg files. Every time I want to upload, I... (6 Replies)
Discussion started by: spidydude
6 Replies

4. UNIX for Dummies Questions & Answers

Changing file extension

Hello all, I need to change file extension for all .doc files to .txt file in multiple folders. I know the way to rename them by going to each folder and doing that, but I need something which I can run from home directory so that It does the renaming in all the nested directories. Thanks. (4 Replies)
Discussion started by: jaysean
4 Replies

5. Shell Programming and Scripting

Changing file names

I have lot of files whose names are something like the following. I want to change the name of all the files from 'npt02' to 'n02'. npt02-z30-sr65-rgdt0p50-dc0p01-16x12drw.tpf npt02-z30-sr65-rgdt0p50-dc0p01-8x6drw.back npt02-z30-sr65-rgdt0p50-dc0p01-8x6drw-bst-mis.xy... (5 Replies)
Discussion started by: kristinu
5 Replies

6. Shell Programming and Scripting

[SOLVED] Changing file names

I have written a csh script that changes the name of file from src to dst. I am getting the error below: TESTAmvfiles DONE TESTAmvfiles set: Variable name must begin with a letter. The csh script is: #!/bin/csh #... (0 Replies)
Discussion started by: kristinu
0 Replies

7. Shell Programming and Scripting

Changing file extension in csh alias

I want to type only the filename of a gcc source that has ".syn" as an extension and copy it, changing the extension to ".c" so it can be compiled. I do it as follows: if (-e $1.syn) then /bin/cp $1.syn $1.c endif This works fine, but if I want to repeat the compilation by... (1 Reply)
Discussion started by: ygmwayne
1 Replies

8. Shell Programming and Scripting

Changing file names

I have file names as shown and want to change the name to have only the first four numbers. /home/chrisd/Desktop/nips/nips_2013/5212-learning-feature-selection-dependencies-in-multi-task-learning.pdf /home/chrisd/Desktop/nips/nips_2013/5213-parametric-task-learning.pdf... (3 Replies)
Discussion started by: kristinu
3 Replies

9. Shell Programming and Scripting

Changing file names

I have a series of files as follows file-1.pdf file-2.pdf file-3.pdf file-4.pdf file-5.pdf file-6.pdf file-7.pdf I want to have the file names with odd numbers starting from an initial number, for example 2000. The result would be the following: file-2001.pdf file-2003.pdf... (9 Replies)
Discussion started by: kristinu
9 Replies

10. Shell Programming and Scripting

Changing file names

sac_pzs_iv_epoz_hhe__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_epoz_hhn__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_epoz_hhz__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_haga_hhe__2006.111.00.00.00.0000_2599.365.23.59.59.99999... (3 Replies)
Discussion started by: kristinu
3 Replies
EXIMSTATS(8)							       EXIM4							      EXIMSTATS(8)

NAME
eximstats - generates statistics from Exim mainlog or syslog files. SYNOPSIS
eximstats [Output] [Options] mainlog1 mainlog2 ... eximstats -merge [Options] report.1.txt report.2.txt ... > weekly_report.txt Output: -txt Output the results in plain text to STDOUT. -txt=filename Output the results in plain text. Filename '-' for STDOUT is accepted. -html Output the results in HTML to STDOUT. -html=filename Output the results in HTML. Filename '-' for STDOUT is accepted. -xls Output the results in Excel compatible Format to STDOUT. Requires the Spreadsheet::WriteExcel CPAN module. -xls=filename Output the results in Excel compatible format. Filename '-' for STDOUT is accepted. Options: -hnumber histogram divisions per hour. The default is 1, and 0 suppresses histograms. Valid values are: 0, 1, 2, 3, 5, 10, 15, 20, 30 or 60. -ne Don't display error information. -nr Don't display relaying information. -nr/pattern/ Don't display relaying information that matches. -nt Don't display transport information. -nt/pattern/ Don't display transport information that matches -qlist List of times for queuing information single 0 item suppresses. -tnumber Display top <number> sources/destinations default is 50, 0 suppresses top listing. -tnl Omit local sources/destinations in top listing. -t_remote_users Include remote users in the top source/destination listings. -include_original_destination Include the original destination email addresses rather than just using the final ones. Useful for finding out which of your mailing lists are receiving mail. -show_dtlist Show the delivery times (DT)for all the messages. Exim must have been configured to use the +deliver_time logging option for this option to work. list is an optional list of times. Eg -show_dt1,2,4,8 will show the number of messages with delivery times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -show_rtlist Show the receipt times for all the messages. The receipt time is defined as the Completed hh:mm:ss - queue_time_overall - the Receipt hh:mm:ss. These figures will be skewed by pipelined messages so might not be that useful. Exim must have been configured to use the +queue_time_overall logging option for this option to work. list is an optional list of times. Eg -show_rt1,2,4,8 will show the number of messages with receipt times under 1 second, 2 seconds, 4 seconds, 8 seconds, and over 8 seconds. -byhost Show results by sending host. This may be combined with -bydomain and/or -byemail and/or -byedomain. If none of these options are specified, then -byhost is assumed as a default. -bydomain Show results by sending domain. May be combined with -byhost and/or -byemail and/or -byedomain. -byemail Show results by sender's email address. May be combined with -byhost and/or -bydomain and/or -byedomain. -byemaildomain or -byedomain Show results by sender's email domain. May be combined with -byhost and/or -bydomain and/or -byemail. -pattern Description /Pattern/ Look for the specified pattern and count the number of lines in which it appears. This option can be specified multiple times. Eg: -pattern 'Refused connections' '/refused connection/' -merge This option allows eximstats to merge old eximstat reports together. Eg: eximstats mainlog.sun > report.sun.txt eximstats mainlog.mon > report.mon.txt eximstats mainlog.tue > report.tue.txt eximstats mainlog.wed > report.web.txt eximstats mainlog.thu > report.thu.txt eximstats mainlog.fri > report.fri.txt eximstats mainlog.sat > report.sat.txt eximstats -merge report.*.txt > weekly_report.txt eximstats -merge -html report.*.txt > weekly_report.html o You can merge text or html reports and output the results as text or html. o You can use all the normal eximstat output options, but only data included in the original reports can be shown! o When merging reports, some loss of accuracy may occur in the top n lists. This will be towards the ends of the lists. o The order of items in the top n lists may vary when the data volumes round to the same value. -charts Create graphical charts to be displayed in HTML output. Only valid in combination with -html. This requires the following modules which can be obtained from http://www.cpan.org/modules/01modules.index.html GD GDTextUtil GDGraph To install these, download and unpack them, then use the normal perl installation procedure: perl Makefile.PL make make test make install On Debian GNU/Linux you can use "apt-get install libgd-perl libgd-text-perl libgd-graph-perl" instead. -chartdirI <dir> Create the charts in the directory <dir> -chartrelI <dir> Specify the relative directory for the "img src=" tags from where to include the charts -emptyok Specify that it's OK to not find any valid log lines. Without this we will output an error message if we don't find any. -d Debug flag. This outputs the eval()'d parser onto STDOUT which makes it easier to trap errors in the eval section. Remember to add 1 to the line numbers to allow for the title! DESCRIPTION
Eximstats parses exim mainlog and syslog files to output a statistical analysis of the messages processed. By default, a text analysis is generated, but you can request other output formats using flags. See the help (-help) to learn about how to create charts from the tables. AUTHOR
There is a web site at http://www.exim.org TO DO
This program does not perfectly handle messages whose received and delivered log lines are in different files, which can happen when you have multiple mail servers and a message cannot be immediately delivered. Fixing this could be tricky... Merging of xls files is not (yet) possible. Be free to implement :) perl v5.14.2 2014-07-24 EXIMSTATS(8)
All times are GMT -4. The time now is 02:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy