Home » Infrastructure » Unix » How to change the multiple file names in unix
How to change the multiple file names in unix [message #601099] Fri, 15 November 2013 12:13 Go to next message
ramyadavoracle@gmail.com
Messages: 22
Registered: May 2013
Location: Bangalore
Junior Member
we are developed java code,this java code is called in unix scripts so when ever we are run this unix scrips 22 files are generated and we are moved to one directory.
The file names like P.40.LZ_BUS_JSTFCTN_DSAS.90091915.2_4_4.20131031.110957,P.40.LZ_DEAL_DSAS.90091915.2_4_4.20131031.110957 etc but all files have consists _DSAS so now i want romove the _DSAS text in each file can you possible to change in all the files in one command or any way to change the files.So any one knows please let me know ASAP.

Thanks in Advance for your help.

Regards,
Ramesh

[Updated on: Fri, 15 November 2013 12:17]

Report message to a moderator

Re: How to change the multiple file names in unix [message #601100 is a reply to message #601099] Fri, 15 November 2013 12:17 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
rm -f *_DSAS*
Re: How to change the multiple file names in unix [message #601101 is a reply to message #601100] Fri, 15 November 2013 12:20 Go to previous messageGo to next message
ramyadavoracle@gmail.com
Messages: 22
Registered: May 2013
Location: Bangalore
Junior Member
thanks a lot .....for your quick replay

i think here files are removed with the name having *_DSAS* correct?.But i want the rename the files without _DSAS only no need to remove the files.
for that it is working?

[Updated on: Fri, 15 November 2013 12:26]

Report message to a moderator

Re: How to change the multiple file names in unix [message #601102 is a reply to message #601101] Fri, 15 November 2013 13:01 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
[oracle@localhost ~]$ ls -1 *sql > files1.txt
[oracle@localhost ~]$ cat double.pl 
open(DAT,'files1.txt');
open(OUT,'>files2.txt');
while ( <DAT> ) {
   $line=$_;
   chop($line);
     print OUT "$line $line\n";
}
close DAT;
close OUT;
[oracle@localhost ~]$ perl double.pl 
[oracle@localhost ~]$ cat files2.txt
123.sql 123.sql
age1.sql age1.sql
age.sql age.sql
apxchpwd.sql apxchpwd.sql
a.sql a.sql
books.sql books.sql
bw.sql bw.sql
createViews.sql createViews.sql
date.sql date.sql
dblink.sql dblink.sql
ddl.sql ddl.sql
default.sql default.sql
error.sql error.sql
except.sql except.sql
fix.sql fix.sql
fk.sql fk.sql
line1.sql line1.sql
pk.sql pk.sql
procedure_name.sql procedure_name.sql
raw.sql raw.sql
reset_OE.sql reset_OE.sql
reset_xdbPorts.sql reset_xdbPorts.sql
role.sql role.sql
scott.sql scott.sql
seq.sql seq.sql
spoolit.sql spoolit.sql
sql1.sql sql1.sql
ssc.sql ssc.sql
team.sql team.sql
timings.sql timings.sql
utl_file.sql utl_file.sql
with.sql with.sql
[oracle@localhost ~]$ 


you can then manually edit files2.txt to include the rename command & remove the unwanted string; "_DSAS"
Re: How to change the multiple file names in unix [message #601672 is a reply to message #601101] Sun, 24 November 2013 03:07 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
ramyadavoracle@gmail.com wrote on Fri, 15 November 2013 23:50
i want the rename the files without _DSAS


Have a look at this thread
Previous Topic: Can't login to storage: File sistem is full
Next Topic: HOST command
Goto Forum:
  


Current Time: Fri Nov 22 16:31:40 CST 2024