renaming with wild chars


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting renaming with wild chars
# 1  
Old 03-13-2006
renaming with wild chars

Hi,
Is it possible to rename with wild charaters as destination name

ex
I wanna rename xxx_1010_zzz_0.txt to aaa_1010_zzz_1.txt,
yyy_1000_ppp_1.txt to bbb_1000_ppp.0.txt

I wanna reatin some of the patterns in the filename, rest I wanna rename.
like
mv ETL_Account_20051217_001_1.tsv aaa_*_1.txt

I know the above is incorrect statement, but I wanna acheve what it refers to. Is that possible ?
# 2  
Old 03-14-2006
You could use character substitution, such as:

Code:
patt=ETL

for a in ${patt}*
do
  mv $a aaa${a#$patt}
done

This strips ETL from the start of the file names of all files starting ETL and then prefixes the names with aaa, so:
moves ETL_Account_20051217_001_1.tsv to aaa_Account_20051217_001_1.tsv
moves ETL_Account_20051218_001_1.tsv to aaa_Account_20051218_001_1.tsv
moves ETL_Account_20051219_001_1.tsv to aaa_Account_20051219_001_1.tsv

etc...

any good to you?

cheers
# 3  
Old 03-14-2006
Hi,
Thanks,yes it does.I've modified little bit to include ls command.

Regs
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. UNIX for Dummies Questions & Answers

Renaming a file using wild characters

Hi, I have a file named as StateDCH_CSHCS_100131.txt and the digits in the file name changes everyday. I have to read this file from UTL_FILE package of Oracle 10g. So I want to rename this file picking StateDCH*.txt to StateDCH_Standard.txt a fixed name so that my UTL_FILE utility can be able... (4 Replies)
Discussion started by: master346
4 Replies

3. UNIX for Dummies Questions & Answers

wild char * in if

if ; then => is it correct? i need to check 10 files size and do the same action. The file name is same but extension of the files are different. how do i deal with it? Please help (1 Reply)
Discussion started by: nidhink
1 Replies

4. Solaris

Consoles gone wild!

I have a Sunfire V890 running solaris 10 that has a weird console problem. In the XWindows environment, everything seems to work fine. However, if I go to command-line mode in multi-user mode or otherwise, my prompt scrolls accross the screen so incontrollably, that the only thing you can do is... (5 Replies)
Discussion started by: josephgreensr
5 Replies

5. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

6. AIX

df, grep, wild card

Hi, I want to monitor my filesystem capacity and I want to df with grep wildcard for all 9*%. Is this possible? I want to replaced all the existing complicated scripts I have in the system. Thanks, Itik (2 Replies)
Discussion started by: itik
2 Replies

7. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies

8. UNIX for Dummies Questions & Answers

ls and wild card - Should be simple!

I am trying to cp files that have F0 as prefix in their name in path p1/p2 to path p3/p4 this command does not work - Why? (I am using HP/UX) cp p1/p2/F0* p3/p4 thanks. (2 Replies)
Discussion started by: GNMIKE
2 Replies
Login or Register to Ask a Question