Help removing the prefix of more than 10,000 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help removing the prefix of more than 10,000 files
# 8  
Old 04-02-2008
I was reminde of the "cut" command. The below code seemed to have worked.

Code:
for files in raw_ddd*
do
newfilename=`echo $files | cut -c1-12-`
cp $files $newfilename
done

# 9  
Old 04-02-2008
Quote:
Originally Posted by bbbngowc
Something is not right with this command...

Works fine for me:


Input

Code:
raw_ddd_04_*7893y34hrkgjhvvnn
raw_ddd_04_*pp9485khghkhkjh hhhhh
raw_ddd_04_*kladlgdg fff
aaabbbccc

Output

Code:
7893y34hrkgjhvvnn
pp9485khghkhkjh hhhhh
kladlgdg fff
aaabbbccc

Tested on HP-UX ( B.11.00 )

Last edited by rubin; 04-02-2008 at 11:10 PM.. Reason: OS - HP-UX ( B.11.00 )
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract Uniq prefix from a start and end prefix

Dear All, assume i have a file with content: <Start>6000</Start> <Stop>7599</Stop> the output is: 6000 7000 7100 7200 7300 7400 7599 how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix. Thanks Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies

2. Shell Programming and Scripting

Removing only Prefix string (!)

Hello everyone, I want to remove only prefix ME_ from all the values that are present in the FILEA. Below code I'm using for this. sed 's/ME\_//g' FILEA > FILEB Using the above code, all ME_ values are getting removed from the file. But the problem here is I want to remove only Prefix ME_... (4 Replies)
Discussion started by: ed_9
4 Replies

3. UNIX for Dummies Questions & Answers

Add foldername as prefix to files

Hi there, I am looping through folders in order to rename the files in the current folder. So, given me being a newbie here, I would do that with a for-loop. The renaming per se should be like this: I want to add the folder-name as a prefix to the files in the folder in question. For instance,... (6 Replies)
Discussion started by: jahndavik
6 Replies

4. UNIX for Dummies Questions & Answers

Take 100MB worth files from 200,000 Files

Hi, I have a process which creates almost 200K files. Each file ranging from 1kb to 5kb. This is almost 2GB of data in all files. I have a requirement where the business needs only 100MB worth of files. Is there a way to get files around 100MB (doesn't have to be exactly 100MB) from all the... (2 Replies)
Discussion started by: grep_me
2 Replies

5. UNIX for Dummies Questions & Answers

Removing prefix from multiple files and renaming file extension

Hello i have the files in this format pdb1i0t.ent pdb1lv7.ent pdb1pp6.ent pdb1tj2.ent pdb1xg2.ent pdb2b4b.ent pdb2ewe.ent Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt The new file should look like this ... (3 Replies)
Discussion started by: empyrean
3 Replies

6. News, Links, Events and Announcements

Microsoft "Donates" $3,000,000,000 to Feds

Surreal quote from the news link below: http://www.washingtonpost.com/wp-dyn/articles/A44615-2002Nov12.html (0 Replies)
Discussion started by: Neo
0 Replies
Login or Register to Ask a Question