Renaming files in SunOS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Renaming files in SunOS
# 1  
Old 03-15-2010
Renaming files in SunOS

Hi,

I have 200+ files in Solaris 10 that I'm trying to rename. I have a few methods that worked in AIX but not working in Solaris.

Can some help me rename file like the below with a script please?

example filename: 0310.Date.00.aa.gz

Need to insert '133': 0310.Date.00.aa.133.gz

Thanks.
# 2  
Old 03-15-2010
Code:
#!/bin/ksh
a='0310.Date.00.aa.gz'

echo "mv ${a} ${a%.gz}.133.gz"

# 3  
Old 03-15-2010
Thanks.

I got it to work using the below:

Code:
for file in *.pp.gz 
do echo "mv ${file} ${file%.*}.133.gz"
 done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Manipulate files with find and fuser not working as expected on SunOs

Greetings, For housekeeping, I use the following command: find /some/path -type f -name "*log*" ! -exec fuser -s "{}" 2>/dev/null \; -exec ls -lh {} \; It finds all log files not currently in use by a process and manipulates them. This command always works on linux and redhat machines,... (2 Replies)
Discussion started by: dampio
2 Replies

2. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

3. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

4. UNIX for Dummies Questions & Answers

renaming all files

requirement: There are many files inside a directory and all are named like this "out_1". The file names goes on itearation like out_2, out_3 etc.... Now i want to rename all the file names based on the text inside the file. the text in all the files follow a pattern like it satrts... (4 Replies)
Discussion started by: arunmanas
4 Replies

5. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

6. Solaris

Need to transfer files over from an olds Sunos 5.6 box

Hi, I have an ancient SunOS 5.6 and I have to backup all the data onto it. I have tried connecting a tape drive but it does not boot up (something to do with its SCSI configuration I guess) when I do. So I am left with the possibility of copying files remotely from the SunOs box to another... (3 Replies)
Discussion started by: mojoman
3 Replies

7. Solaris

Read/View .img files from SunOs 5.8

We use imaging software from a cardiology clinic on SunOS 5.8 and I want to be able to see these image files (.img extension) on Windows XP. Can this be done? If so, with what software (on Windows XP)? On Windows XP, I've used software like Ulead PhotoImpact and Corel PhotoPaint but I've had no... (16 Replies)
Discussion started by: sreyes27
16 Replies

8. Solaris

help retrieving files from SunOS 5.8

Hi, I am trying to get a small amount of files off of a SunBlade 2000 running SunOS 5.8, but I'm having trouble finding a medium that will actually work. It is not networked, and it doesn't have a writable CD drive. My only options seem to be floppy disk and USB drive. However, when I insert... (11 Replies)
Discussion started by: ryanm
11 Replies

9. UNIX for Dummies Questions & Answers

renaming files

Hello all- I need to rename files by adding an embedded 0 e.g. aaa_bbb_1234 needs to become aaa_bbb_01234 The aaa and 1234 will change but the bbb_ can be my anchor. TIA (9 Replies)
Discussion started by: ohagar
9 Replies

10. UNIX for Advanced & Expert Users

Migration of binary file from Sunos 5.8 to Sunos 5.9

I have compiled binary file using "cc" on SunOS 5.8 and the same binary file i have copied to SunOS 5.9 and it is giving me core dump error.I want to know whether migration of compiled code from lower version to higer version created this problem. how can i solve this problem.I am pasting the core... (1 Reply)
Discussion started by: Arvind Maurya
1 Replies
Login or Register to Ask a Question