Sponsored Content
Top Forums Shell Programming and Scripting Rename file using sed command Post 302416949 by Franklin52 on Wednesday 28th of April 2010 06:11:03 AM
Old 04-28-2010
Quote:
Originally Posted by fanny_tirtasari
Hi Franklin, i copied paste your code but end up with "ksh: syntax error: `(' unexpected
".

Any advise?
Hmm, works fine for me, try this, but try first without the coloured part:
Code:
ls DOC*.xml' |
awk -v dat=$(date +"DOC%Y%m%d%H%M%S") ' {
of=sprintf("%02d.xml",++c)
print "mv " $0 " " dat of
}' | sh

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

2. Shell Programming and Scripting

mv command to rename multiple files that retain some portion of the original file nam

Well the title is not too good, so I will explain. I need to move (rename) files using a simple AIX script. ???file1.txt ???file2.txt ???file1a.txt ???file2a.txt to be: ???renamedfile1'date'.txt ???renamedfile2'date'.txt ???renamedfile1a'date'.txt ???renamedfile2a'date'.txt ... (4 Replies)
Discussion started by: grimace15
4 Replies

3. UNIX for Advanced & Expert Users

Unix Command to rename a file in a zipped folder

Hi, I am into automation work. Is there any UNIX command to rename a file in a zipped folder, without unzipping it..??? Thanks in advance.. (1 Reply)
Discussion started by: Victoria.Sam
1 Replies

4. Shell Programming and Scripting

Multiple file rename (change in filename in unix with single command

Dear All, Please help ! i ham having 300 file with E.G. PMC1_4567.arc in seq. like PMC1_4568.arc,PMC1_4569.arc ...n and so on.. i want all those file to be rename like PMC_4567.arc ,PMC_4568.arc .. mean i want to remove 1 from first file name .. pls help.. (6 Replies)
Discussion started by: moon_22
6 Replies

5. Shell Programming and Scripting

try to batch rename using sed (if this is best)

hi gooday I need some help with a rename I am attempting. I'd like to rename a bunch of files in a folder example list.dat.old to list_N.dat query.dat.old to query_N.dat note the two periods in (.dat.old) to become _N.dat I tried using sed like this ls *.dat.old | sed... (3 Replies)
Discussion started by: johnstrong
3 Replies

6. Shell Programming and Scripting

Rename file using sed or awk

I have a filename like 1_DATE_3_4.5_888 and I want to modify the date field (ie the last 4 digits ) alone and remove the last field. Old filename:1_DATE_3_4.5_888 Given date (for eg):120606259532 modified date:120606259899 new filename:1_<modified date>_3.4.5 (14 Replies)
Discussion started by: sandy88
14 Replies

7. Shell Programming and Scripting

sed file rename

Ubuntu -very new to shell scripts/Linux I have many pictures with "FAMILY", "family" mixed in the file name and not all in the same directory; I want to remove "family" case insensitive from the filenames; find /media/Rock/pics/pics_bak/ -type f "*family*" | sed 's#family##gI' # works for... (2 Replies)
Discussion started by: jennyjones
2 Replies

8. UNIX for Dummies Questions & Answers

Rename scripts using xargs/sed

Morning all I've got loads of scripts but the names are too long! I've stuck the list in a flat file (names) and I'm trying to read that in line by line and create the new names (in to directory new) from the list. It looks like this: xargs -n1 -I{} <names cat {} | sed... (1 Reply)
Discussion started by: Grueben
1 Replies

9. Shell Programming and Scripting

Command / script to partially rename file

Hi I have numerous files names product_host_result_B1000842.txt product_host_result_B1000847.txt product_host_result_C1000842.txt product_host_result_C1000848.txt etc. I need them renamed so that the 'product_host_result' becomes 'output_product_host' but the rest of the filename is... (6 Replies)
Discussion started by: Grueben
6 Replies

10. UNIX for Dummies Questions & Answers

sed replace to rename each line a file

Have a file in this format This is line one ; line_one This is line two ; line_two This is line three ; line_three This is line four ; line four. I'm trying to make each line a new file called line_one line_two line_three line_four. Tried using split -1 but then I'm back needing to rename... (3 Replies)
Discussion started by: jimmyf
3 Replies
DOC(4)							     Kernel Interfaces Manual							    DOC(4)

NAME
DOC - (Pilot standard text document) file format SYNOPSIS
struct doc_record0 { /* 16 bytes total */ Word version; /* 1 = plain text, 2 = compressed text */ Word reserved1; DWord doc_size; /* uncompressed size in bytes */ Word num_recs; /* not counting itself */ Word rec_size; /* in bytes: usually 4096 (4K) */ DWord reserved2; }; DESCRIPTION
The Doc file format is the standard text document format used by all models of the Palm Pilot. A Doc file is a pdb(4) file: this manual page describes only those aspects specific to Doc files. A Doc file consists of 0 to num_recs records; record 0 is the header for the document. (This header is distinct from the pdb(4) header.) The remaining records contain text, either plain or compressed depending upon version. Word Sizes In the synopsis above, the types ``Word'' and ``DWord'' are used just as in the Pilot headers. The type ``Word'' is 16 bits; the type ``DWord'' is 32 bits. Both are in big-endian format. Compression Format A character ``c'' in a compressed record is in one of four classes: 01-08 Copy ``c'' bytes 00,09-7F Self 80-BF Sequence C0-FF A space plus the ASCII character ``c ^ 0x80'' SEE ALSO
txt2pdbdoc(1), html2pdbtxt(1), pdbtxt2html(1), pdb(4) Christopher Bey and Kathleen Dupre. Palm File Format Specification, Document Number 3008-003, Palm, Inc., May 16, 2000. AUTHOR
Paul J. Lucas <pauljlucas@mac.com> txt2pdbdoc January 21, 2005 DOC(4)
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy