Sponsored Content
Top Forums Shell Programming and Scripting How to rename lots of files with find? Post 302934552 by bartus11 on Sunday 8th of February 2015 03:12:42 PM
Old 02-08-2015
Try:
Code:
find . -name 22\* | while read old; do 
    new=`echo $old | perl -nle '/_(\d+)_/&&print "ch$1"'`
    mv $old $new
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting lots of files.....

Hi All, Thanks in advance for reading and any posts... I have to delete a lot of files (about 6 pages of a4 (ls -ltr)) but I have to keep some as well. I would normally do an rm * to get rid of them all, but thats not what I want to do. Is there anyway I could rm * but add in a list of... (8 Replies)
Discussion started by: B14speedfreak
8 Replies

2. UNIX for Dummies Questions & Answers

Find and rename all folders with name X.

Is there a command I can use to rename all directories with a certain name to a new name. For instance from my root directory I want to change all folders named '123' to '321' that are in the root directory or any subdirectory. Thanks in advance! (6 Replies)
Discussion started by: mkingrey
6 Replies

3. Shell Programming and Scripting

Find, Append, Move & Rename Multiple Files

Using a bash script, I need to find all files in a folder "except" the newest file. Then I need to insert the contents of one text file into all the files found. This text needs to be placed at the beginning of each file and needs a blank line between it and the current contents of the file. Then I... (5 Replies)
Discussion started by: Trapper
5 Replies

4. Shell Programming and Scripting

Find and rename

Hi, I was wondering if there is a way to find a particular file and then give it as an input to a program and then dump it into another file. Something like this: find ./ -name '*.txt' -exec ~/processText {} > mod.<current_file> \; I've been trying all sorts of weird things but not... (2 Replies)
Discussion started by: Legend986
2 Replies

5. UNIX for Advanced & Expert Users

How to find one partucular user logs when there are lots of users running on it

On my application there are lots of users are doing there work or tasks? ...In my SSH or in 'Putty' i am observing logs? Hot to observe one particular 'user' logs.. even through there are lots of users working on it? For EX: i am log in with use rid:nikhil@in.com. another one log in with... (4 Replies)
Discussion started by: ksr.test
4 Replies

6. Shell Programming and Scripting

Find last updated files and rename

HI I have a requirement to find the last updated files from a directory whcih has subdirectories and inside them we have files with .txt,.doc,.xls .. extensions. i have to find those files which were updated in the last 1hr and rename the files with respective <sub-directory>_<filename> and copy... (3 Replies)
Discussion started by: ramse8pc
3 Replies

7. Shell Programming and Scripting

Find and Rename files using (find mv and sed)

In response to a closed thread for degraff63 at https://www.unix.com/shell-programming-scripting/108882-using-mv-find-exec.html the following command might do it as some shells spit it without the "exec bash -c " part: Find . -name "*.model" -exec bash -c "mv {} \`echo {} | sed -e 's//_/g'\`"... (0 Replies)
Discussion started by: rupert160
0 Replies

8. Shell Programming and Scripting

Find directories with same name and rename them

Hello Im trying to make a script in bash shell programming to find subdirectories with the same name into the same directory and rename one of them!! Could you please help me? Thanks in advance (1 Reply)
Discussion started by: BTKBaaMMM
1 Replies

9. UNIX for Advanced & Expert Users

Find Gzip rename and mv

Hi all, what i'm trying to configure its to the following, find all files older then 1 min,gzip them ,rename/move with date and extension .gz (example tes.log_2012-07-26.gz) and trying to move them to another folder (gzipped),the command i'm typing its this, find /home/charli/Desktop/test/ -type... (4 Replies)
Discussion started by: charli1
4 Replies

10. Shell Programming and Scripting

Trying to find and rename files

but it's not working. Hello all. I'm running the following command to find files with a specific name and rename them, but the command prompt returns a short 10 seconds after executing and doesn't find or rename anything. What am I doing wrong here? find . -type f | for file in... (3 Replies)
Discussion started by: bbbngowc
3 Replies
DH_METAINIT(1)						User Contributed Perl Documentation					    DH_METAINIT(1)

NAME
dh_metainit - install metainit files into package build directories SYNOPSIS
dh_metainit [debhelper options] [--name=name] [-n] [-o] DESCRIPTION
dh_metainit is a debhelper program that is responsible for installing metainit files (for further creation of initscripts via the update- metainit facility) into package build directories. It also automatically generates the postinst and postrm and prerm commands needed to create the appropriate initscripts for the init system employed on the user machine. Important: If generated postinst script finds /etc/init.d/ or /etc/default files with the same name as the shipped metainit files, and these are conffiles from non-installed packages (probably earlier version of this package) they are removed (or renamed if the user has modified them). This works only if the name of the new metainit is the same as the name of the old init.d and default file, otherwise you will have to remove these files yourself. See http://wiki.debian.org/DpkgConffileHandling for that. If a file named debian/package.metainit exists, then it is installed into etc/metainit/package in the package build directory, with "pack- age" replaced by the package name. OPTIONS
-n, --noscripts Do not modify postinst/postrm/prerm scripts. -o, --onlyscripts Only modify postinst/postrm/prerm scripts, do not actually install any metainit files. May be useful if the init script is shipped and/or installed by upstream in a way that doesn't make it easy to let dh_metainit find it. --name=name Install the metainit script using the filename name instead of the default filename, which is the package name. When this parameter is used, dh_metainit looks for and installs files named debian/package.name.metainit, instead of the usual debian/package.init. --error-handler=function Call the named shell function if running the init script fails. The function should be provided in the prerm and postinst scripts, before the #DEBHELPER# token. NOTES
Note that this command is not idempotent. "dh_clean -k" should be called between invocations of this command. Otherwise, it may cause mul- tiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Urs Ganse <urs@nerd2nerd.org> based on dh_installinit by Joey Hess <joeyh@debian.org> perl v5.8.8 2007-07-30 DH_METAINIT(1)
All times are GMT -4. The time now is 01:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy