Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Changing the file name format Post 302920467 by Aia on Thursday 9th of October 2014 02:17:53 PM
Old 10-09-2014
Code:
#!/bin/bash

for f in *_M-130_*.root; do
    keep="${f%_?_???.root}"
    if [[ "$keep" != "$f" ]]; then
        echo mv "$f" "${keep}.root"
    fi
done


Last edited by Aia; 10-09-2014 at 03:56 PM.. Reason: add a minimal of validation
This User Gave Thanks to Aia For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

changing format

Dear Experts, Currently my script is gereating the output like this as mentioned below. 8718,8718,0,8777 7450,7450,0,7483 5063,5063,0,5091 3840,3840,0,3855 3129,3129,0,3142 2400,2400,0,2419 2597,2597,0,2604 3055,3055,0,3078 4249,4249,0,4266 4927,4927,0,4957 8920,8920,0,8978... (4 Replies)
Discussion started by: shary
4 Replies

2. UNIX for Dummies Questions & Answers

Changing display and format of file

I have an input file which looks like this: 601 a 602 a 603 a 601 b 610 c 615 c 603 d 601 d 612 d I need the utput to look like this 601 a 602 603 602 a 601 603 603 a 601 602 601 b 610 c 615 615 c 610 603 d 601 612 (1 Reply)
Discussion started by: wahi80
1 Replies

3. Shell Programming and Scripting

changing month in Mmm format to mm FORMAT

i have an variable mydate=2008Nov07 i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month) i want some command to do this for any month without using any loop. plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies

4. Shell Programming and Scripting

changing the format of CSV file

Hi Experts, Please help me to get the following from script for Unix ENvironment(shell, perl, tr, sed, awk). INPUT FILE: 20K,ME,592971 20K,YOU,2 20K,HE,1244998 50K,YOU,480110 50K,ME,17 50K,HIS,10 50K,HE,1370391 OUTPUT FILE: K,ME,YOU,HE,HIS 20K,592971,2,1244998,0... (5 Replies)
Discussion started by: ashis.tewari
5 Replies

5. Shell Programming and Scripting

Changing the text file format

Hi, I have a shell script to unload all the empname who have salary >50000 from the emp table into a text file(empname.txt) . m_db unload "$dbc_file" -column_delimiter ',' -select "SELECT empname FROM emp where salary > 50000" >> empname.txt Now my text file have data in the following format ... (3 Replies)
Discussion started by: kavithakuttyk
3 Replies

6. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

7. Shell Programming and Scripting

how I can add a constant to a field without changing the file format

Hi, I need to edit a file Protein Data Bank (pdb) and then open that file with the program VMD but when I edit the file with awk, it changes pdb format and the VMD program can not read it. I need to subtract 34 to field 6 ($ 6). this is a pdb file : ATOM 918 N GLY B 103 -11.855 8.675... (8 Replies)
Discussion started by: bio_
8 Replies

8. Shell Programming and Scripting

Command for changing date format in a file

Hi... I have an inputfile name as :- abc_test_20120213.dat (date in yyyymmdd format) I need the output file name as abc_test_13022012.dat (date in ddmmyyyy format) Please help me on this... Thanks in advance. (5 Replies)
Discussion started by: gani_85
5 Replies

9. Shell Programming and Scripting

Changing date format in CSV file

I have a CSV file with a date format like this; 11/19/2012 17:37:00,1.372,121.6 11/19/2012 17:38:00,0.743,121.6 Want to change the time stamp to seconds after 1970 so I can get the data in rrdtool. For anyone interested, this is data from a TED5000 unit and is Kwatts and volts. Needs to... (3 Replies)
Discussion started by: ottsm
3 Replies

10. Shell Programming and Scripting

Changing format of file with awk

Hi all, I have a file that looks like this: Closest words to: manifesto >>>> Closest words to: passport >>>> and I want to reformat this with awk with the following desired result: manifesto 0.99999999999999978, 'manifesto' 0.72008211381623111, 'communiqu\xe9'... (5 Replies)
Discussion started by: owwow14
5 Replies
pkgproto(1)							   User Commands						       pkgproto(1)

NAME
pkgproto - generate prototype file entries for input to pkgmk command SYNOPSIS
pkgproto [-i] [-c class] [path1] pkgproto [-i] [-c class] [path1=path2...] DESCRIPTION
pkgproto scans the indicated paths and generates prototype(4) file entries that may be used as input to the pkgmk(1) command. If no paths are specified on the command line, standard input is assumed to be a list of paths. If the pathname listed on the command line is a directory, the contents of the directory is searched. However, if input is read from stdin, a directory specified as a pathname will not be searched. OPTIONS
-i Ignores symbolic links and records the paths as ftype=f (a file) versus ftype=s (symbolic link). -c class Maps the class of all paths to class. OPERANDS
path1 Pathname where objects are located. path2 Pathname which should be substituted on output for path1. EXAMPLES
Example 1: Examples of the use of pkgproto.1. The following two examples show uses of pkgproto and a partial listing of the output produced. Example 1: example% pkgproto /bin=bin /usr/bin=usrbin /etc=etc f none bin/sed=/bin/sed 0775 bin bin f none bin/sh=/bin/sh 0755 bin daemon f none bin/sort=/bin/sort 0755 bin bin f none usrbin/sdb=/usr/bin/sdb 0775 bin bin f none usrbin/shl=/usr/bin/shl 4755 bin bin d none etc/master.d 0755 root daemon f none etc/master.d/kernel=/etc/master.d/kernel 0644 root daemon f none etc/rc=/etc/rc 0744 root daemon Example 2: example% find / -type d -print | pkgproto d none / 755 root root d none /bin 755 bin bin d none /usr 755 root root d none /usr/bin 775 bin bin d none /etc 755 root root d none /tmp 777 root root EXIT STATUS
0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
pkgmk(1), pkgparam(1), pkgtrans(1), prototype(4), attributes(5) Application Packaging Developer's Guide NOTES
By default, pkgproto creates symbolic link entries for any symbolic link encountered (ftype=s). When you use the -i option, pkgproto cre- ates a file entry for symbolic links (ftype=f). The prototype(4) file would have to be edited to assign such file types as v (volatile), e (editable), or x (exclusive directory). pkgproto detects linked files. If multiple files are linked together, the first path encountered is considered the source of the link. By default, pkgproto prints prototype entries on the standard output. However, the output should be saved in a file (named Prototype or prototype, for convenience) to be used as input to the pkgmk(1) command. SunOS 5.10 6 Nov 2000 pkgproto(1)
All times are GMT -4. The time now is 09:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy