01-21-2008
multiple file renaming
say you have files like below...
jordba.package1
jordba.package2
jordba.package3
use the below:
for f in jordba.*; do mv "$f" "${f#jordba.}"; done
the above for loop will make your list like...
package1
package2
package3
========================
but there is another issue similar to the before that i have the files
x1_p.sql
x2_p.sql
x3_p.sql
and so on
i need to add h before .sql to be as the following:
x1_ph.sql
x2_ph.sql
x3_ph.sql
====================================
This should work for the data given by you above...
for f in *_p.sql ; do mv "$f" "${f%_p.sql}_ph.sql"; done
I hope these r helpful
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all,
I need to replace automatically all special characters of one filename with some corresponding characters
For example >
ö --> oe
ä --> ae
....
If the special character comes more than one time, then all the coccuerences have to be replaced.
I would like to have a... (6 Replies)
Discussion started by: MAKY
6 Replies
2. Shell Programming and Scripting
Sun Solaris Unix Question
Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies
3. Shell Programming and Scripting
Hello,
I have some files in a directory like:
01_07_2010_aa.txt
01_07_2010_bb.txt
01_07_2010_cc.txt
01_07_2010_dd.txt
01_07_2010_ee.txt
01_07_2010_ff.txt
I want to change their names to :
3nm_aa.txt
3nm_bb.txt
3nm_cc.txt
3nm_dd.txt
3nm_ee.txt
3nm_ff.txt (8 Replies)
Discussion started by: ad23
8 Replies
4. Shell Programming and Scripting
got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies
5. Shell Programming and Scripting
Hi is it possible to change multiple files (~10k) names with out disturbing the data in it. ?
input
Hynda|cgr10(+):100027702-1000312480|.txt
Hynda|cgr10(+):100027702-1000312483|.txt
Hynda|cgr10(+):100027702-1000312484|.txt
Hynda|cgr10(+):100027702-1000312482|.txt
output... (4 Replies)
Discussion started by: quincyjones
4 Replies
6. Red Hat
admin.campaign.sql
admin.cardnumber_filter.sql
understand that rename is using mv command but how do I rename such that it become the following:
campaign.sql
cardnumber_filter.sql
thanks (2 Replies)
Discussion started by: jediwannabe
2 Replies
7. UNIX for Dummies Questions & Answers
I have fasta files with multiple sequences in each. I need to change the sequence name headers from:
>accD:_59176-60699
ATGGAAAAGTGGAGGATTTATTCGTTTCAGAAGGAGTTCGAACGCA
>atpA_(reverse_strand):_showing_revcomp_of_10525-12048
ATGGTAACCATTCAAGCCGACGAAATTAGTAATCTTATCCGGGAAC... (2 Replies)
Discussion started by: tyrianthinae
2 Replies
8. Shell Programming and Scripting
Hi,
How can I change following file name in a bash script?
From file names: myfile-module-1.0-3.0.el6.x86_64.package
To file names: myfile-module1_0-1.0-3.0.el6.x86_64.package
^ ^ ^ ^ ^ ^ ^ ^
Basically, the digit 1.0 is a version number, the digit 3.0 is... (11 Replies)
Discussion started by: hce
11 Replies
9. Shell Programming and Scripting
Hi,
I have a files in a directory as below :-
ls -1
mqdepth-S1STC02
proc-mq-S1STC01
proc-mq-S1STC02
proc-mq-S1STC03
Whereever i have S1STC i need to copy them into new file with file name S2STC.
expected output :-
ls -1
mqdepth-S2STC02
proc-mq-S2STC01
proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies
10. Shell Programming and Scripting
I have a landing directory on my unix (solaris) server, that receives the following files:
MLH4301I AAOT-hhslog.610.20150805.txt
MLH4301I AAOT-hhslog.611.20150805.txt
MLH4301I AAOT-hhslog.612.20150805.txt
MLH4301I AAOT-hhslog.613.20150805.txt
and I need to add to this files the number 10000... (6 Replies)
Discussion started by: fretagi
6 Replies
cd_drec(3) Library Functions Manual cd_drec(3)
NAME
cd_drec, cd_cdrec - Reads the Directory Record from a CD-ROM directory
LIBRARY
Rock Ridge and X/Open Extensions to the CDFS library (libcdrom.so, libcdrom.a)
SYNOPSIS
#include <sys/cdrom.h> int cd_drec ( char *path, int fsec, struct iso9660_drec *drec ); int cd_cdrec ( char *path,
int fsec, char *addr );
PARAMETERS
Points to a file or directory within the CD-ROM File System hierarchy.
Specifies the File Section of the file or directory pointed to by *path, with the numbering beginning at one. If fsec is set to -1,
the last File Section of the named file or the only File Section of the named directory is assumed.
Points to the iso9660_drec structure that holds the contents of the Directory Record associated with the file or directory pointed
to by *path. The iso9660_drec structure is defined in cdfs/xcdr.h, an include file that is called into sys/cdrom.h.
Specifies the address to which the function cd_cdrec copies the complete Directory Record that is recorded on the CD-ROM.
DESCRIPTION
The cd_drec routine fills the *drec structure with the contents of the Directory Record that is associated with a file or directory pointed
to by *path.
The cd_cdrec function copies the complete Directory Record from the CD-ROM to the address pointed to by *addr. The user must allocate
{CD_MAXDRECL} bytes for the Directory Record. The variable {CD_MAXDRECL} is defined in cdfs/xcdr.h, an include file that is called into
sys/cdrom.h.
RETURN VALUES
If successful, the value zero is returned.
If unsuccessful, the integer -1 is returned and errno is set to indicate the error.
ERRORS
The function will fail if: Search permission is denied for a directory in *path or read permission is denied for the file or directory
pointed to by *path. The address of *path or *addr is invalid. A signal was caught during execution of the function. The argument *path
points to a file or directory that is not within the CD-ROM file hierarchy.
The value of fsec is invalid. {OPEN_MAX} file descriptors are currently open in the calling process.
[Tru64 UNIX] Either the OPEN_MAX value or the per-process soft descriptor limit is checked. The length of the *path string exceeds
{PATH_MAX}, or a pathname component is longer than {NAME_MAX} while {_POSIX_NO_TRUNC} is in effect. The system file table is full.
A component of *path does not exist, or the *path argument points to an empty string. A component of the *path prefix is not a
directory. The CD-ROM is not in the drive, or a read error occurred.
RELATED INFORMATION
Files: cdfs/xcdr.h, sys/cdrom.h.
delim off
cd_drec(3)