Sponsored Content
Top Forums Shell Programming and Scripting Renaming file that has multiple numbers as filename Post 302772350 by MadeInGermany on Monday 25th of February 2013 06:58:44 AM
Old 02-25-2013
1st trap:
ERE (grep -E or egrep) matches versus glob (wildcard) matches. As RudiC pointed out.
2nd trap:
the shell matches the wildcards against existing files in the current directory.
So the destination cannot be matched.
A way out is a loop, either
Code:
ls | grep -E "partition-setup-and-ipl.vtcmd.[0-9]+" |
while read file
do
 mv "$file" "$file"_org
done

Or
Code:
for file in partition-setup-and-ipl.vtcmd.[0-9]*[0-9]
do
 mv "$file" "$file"_org
done

While the latter is not as precice, because * allows all characters after the [0-9],
I added another [0-9] so at least it does not match the _org files.

Last edited by MadeInGermany; 02-25-2013 at 08:04 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

renaming a compressed file to filename without .Z

In a shell script I would like to use a compressed file name, i.e. with suffix of .Z, as a file input $1. After the file in uncompressed, I would like to use the file name without the .Z . How do I do this? Thank you. (8 Replies)
Discussion started by: bruceps
8 Replies

2. UNIX for Dummies Questions & Answers

Multiple file renaming

Hi All, I have a number of files in a directory that I would like to rename - I am quite aware that you can use the mv command to rename the files - I would like to rename them automatically from the command line instead of having to do them singly. I have searched the forum pertaining to... (4 Replies)
Discussion started by: BigTool4u2
4 Replies

3. Shell Programming and Scripting

Shell Scripts (Renaming file names with sequential numbers)

Hi there, Firstly, I have no experience with shell scripts so would really appreciate some help. I have the following shell script that is causing some problems: moveit() { && set -x if then DOUBLE_DELIVERY=$(grep... (6 Replies)
Discussion started by: thebeno
6 Replies

4. Shell Programming and Scripting

Renaming the filename

Hi, I have several files with name b1.root, b2.root b3.root I want to rename the "b" to "bkg", so finally is should be: bkg1.root bkg2.root bkg3.root I used command: rename s/b/bsig/ b*root Somehow it is working at some place and not working in other folder. I do not have any idea... (3 Replies)
Discussion started by: nrjrasaxena
3 Replies

5. Shell Programming and Scripting

increase/decrease multiple numbers in a filename.

I got a game that output map tiles of the session with the 0,0 position at the place you login/spawn. That makes making a map somewhat troublesome since the 0,0 will move. So I've been looking for a way to change the numbers in the filenames of all files in a folder by a certain value. The... (5 Replies)
Discussion started by: Ravenholdt
5 Replies

6. Shell Programming and Scripting

Renaming a filename

Hi friends , i want to change the filename as below filename=ABC_HYND_JDHD_20130125120345.txt expected output : ABC_HYND_JDHD_20130125.txt i have tried using awk but not able to procedd futher. i am trying to do the above in single commad. echo... (3 Replies)
Discussion started by: i150371485
3 Replies

7. Shell Programming and Scripting

Renaming multiple files at once (discarding suffix of the filename after a character)

Hi, I have a lot of files similar to the below order. I want to rename all the files .discrading the time stamp/numbers after cnf. Existing files id_info_20130405.cnf_20130801 in_info_20130405.cnf_20130891 iz_info_20130405.cnf_20130821 in_info_20130405.cnf_20130818... (2 Replies)
Discussion started by: saravanapandi
2 Replies

8. Shell Programming and Scripting

Multiple File renaming with a twist

Hi I can do simple file renaming but this task is slightly more troublesome Ive got a guy that gives me multiple .pdf filles in a directory named something like 3412345.pdf 4565465.pdf 8534534.pdf And he also gives me a html file which is tabled with which shows the filenames above... (2 Replies)
Discussion started by: messiah1
2 Replies

9. Shell Programming and Scripting

Splitting file into multiple files and renaming them

Hi all, Newbie here. First of all, sorry if I made any mistakes while posting this question in terms of rules. Correct me if I am wrong. :b: I have a .dat file whose name is in the format of 20170311_abc_xyz.dat. The file consists of records whose first column consists of multiple dates in... (2 Replies)
Discussion started by: chanduris
2 Replies

10. UNIX for Beginners Questions & Answers

Renaming files by appending string from within file to filename

Greetings. I am working in a Linux environment and am trying to figure out a way to rename files in a directory by appending a unique strings that appears within a certain area in those files. I have gotten as far as identifying what that particular unique string is with a command like the... (10 Replies)
Discussion started by: HLee1981
10 Replies
CTL_MBOXLIST(8) 					      System Manager's Manual						   CTL_MBOXLIST(8)

 *

NAME
ctl_mboxlist - perform operations on the mailbox list database SYNOPSIS
ctl_mboxlist [ -C config-file ] -d [ -x ] [ -p partition ] [ -f filename ] ctl_mboxlist [ -C config-file ] -u [ -f filename ] ctl_mboxlist [ -C config-file ] -m [ -a ] [ -w ] [ -i ] [ -f filename ] ctl_mboxlist [ -C config-file ] -v [ -f filename ] DESCRIPTION
Ctl_mboxlist is used to perform various administrative operations on the mailbox list database. Ctl_mboxlist reads its configuration options out of the imapd.conf(5) file unless specified otherwise by -C. The configdirectory option is used to determine the default location of the mailbox list database. OPTIONS
-C config-file Read configuration options from config-file. -d Dump the contents of the database to standard output in a portable flat-text format. NOTE: In Cyrus versions 2.2.13 and earlier, the dump format did not include the mailbox type flags, breaking remote mailboxes (frontends, mupdate master, unified backends) when undumped. -x When performing a dump, remove the mailboxes dumped from the mailbox list (mostly useful when specified with -p) -p partition When performing a dump, dump only thise mailboxes that live on partition -u Load the contents of the database from standard input. The input MUST be in the format output using the -d option. NOTE: Both the old and new formats can be loaded, but the old format will break remote mailboxes. -m For backend servers in the Cyrus Murder, synchronize the local mailbox list file with the MUPDATE server. -a When used with -m, assume the local mailboxes file is authoritiative, that is, only change the mupdate server, do not delete any local mailboxes. USE THIS OPTION WITH CARE, as it allows namespace collisions into the murder. -w When used with -m, print out what would be done but do not perform the operations. -i When used with -m, asks for verification before deleting local mailboxes. -v Verify the consistency of the mailbox list database and the spool partition(s). Mailboxes present in the database and not located on a spool partition, and those located on a spool partition (directory containing a valid cyrus.header file) and not present in the database will be reported. Note that this function is very I/O intensive. -f filename Use the database specified by filename instead of the default (configdirectory/mailboxes.db). FILES
/etc/imapd.conf SEE ALSO
imapd.conf(5), cyrus-master(8) CMU
Project Cyrus CTL_MBOXLIST(8)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy