nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Shell scripting - Removing file extension

This is a discussion on Shell scripting - Removing file extension within the Shell scripting forums, part of the Development/Scripting category; I have a bunch of files in a directory and I need to remove everything with a .err back to ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-06-2007, 06:33 AM
Junior Member
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0
urbanreformer
Default Shell scripting - Removing file extension

I have a bunch of files in a directory and I need to remove everything with a .err back to the .dat


PQPZ3.DATR.QRL.R9529.M9097.D090295.T19501.das.1333 332287722.1.2.err

PQPZ3.DATR.QRL.R9529.M9097.D090295.T19501.das
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2007, 01:40 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Do you wanna rename all .err files to .dat? if so use rename command as follow:

Code:
rename 's/\.err$/\.dat/' *.err
To remove .err extension
Code:
rename 's/\.err$//' *.err
More info @ Renaming multiple files at a shell prompt

Let me know if you need any further help ...
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 03-07-2007, 12:15 AM
Junior Member
 
Join Date: Mar 2007
Posts: 2
Rep Power: 0
urbanreformer
Default I can't use rename

AIX ***** 2 5
Reply With Quote
  #4 (permalink)  
Old 03-07-2007, 09:44 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

AIX is old w/o rename command. Anyway you can try something as follows (assuming that you have bash shell):
Code:
 for i in `(find . -name "*.err")`; do mv $i ${i/.err/}; done
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Parse XML file and store data in array in shell scripting Nishanthhampali Shell scripting 5 02-14-2008 12:57 PM
need help on shell scripting rahul_sayz Shell scripting 1 12-08-2007 11:37 AM
Shell Script for adding, removing and commiting the SVN (Subversion system ) anilvrathod Shell scripting 0 12-07-2007 06:40 PM
Books on Shell-Scripting shankar100 Shell scripting 3 02-16-2007 02:19 PM
Learning Shell Scripting ricc Shell scripting 4 08-30-2005 10:37 AM


All times are GMT +5.5. The time now is 07:47 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36