Sponsored Content
Top Forums UNIX for Dummies Questions & Answers renaming files in one commend Post 6779 by fboisvert on Wednesday 12th of September 2001 12:27:21 PM
Old 09-12-2001
Lightbulb renaming files in one commend

How do i rename files ex: file1.txt file2.txt into file1.ttt file2.ttt
in on single statement call.
I have done a awk program that extract the name ex: file file2
but i cannot find a way of using my mv command inside my awk program.
here the code sample
ls *.txt | awk '
{
n = split($1, va, ".")
print va[1]
print $1
mv $1 va[1]".ttt"
}
'
otherwise if you know any thing that will do the same let me know
thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

renaming files

directory name = /usr/tom/1997 files - ABC_1997_ST1_BCD.SQL BCD_1997_ST1_EFG_SAB.SQL TTT_EBC_1997_ST1_A.SQL sub directory - /usr/tom/1997/jan a) I want to just rename the all files ending with '.SQL' and also its contents in the 1997 directory(excluding subdirectories eg... (3 Replies)
Discussion started by: systemsb
3 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Renaming files

Hello! I am not familiar with UNIX and I have this problem: I need to move files from a UNIX machine to a PC. UNIX file names contain ":" as special character which is not recognized in a PC. How can I change ":" for "_" in the name of a bunch of files in UNIX? Thanks for your help. (7 Replies)
Discussion started by: Tygoon
7 Replies

4. Shell Programming and Scripting

Check valid records in really big file with one commend..

Hi, I have a 5 gig file, no record terminators, field terminators are newline. The record length is 768 and I would like to check that every 768th byte is a newline and print out the byte position if it isn't. I would like to do this going either forward or backwards with one command if... (3 Replies)
Discussion started by: vtischuk@yahoo.
3 Replies

5. Shell Programming and Scripting

how to use another account to run commend in the same script

I want to run some script in my own account in one script and meanwhile need to access as root to run some commend and come back to the same script to continue the process. Any idea how the this can be achieved ??? Example: I need to run a script using my id only on 'cuibi' dir, but needs to... (1 Reply)
Discussion started by: cuibiliu
1 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Renaming all files

Hi, Very silly question. I need to rename all my files located in one particular folder. The names are Results1.dis, Results2.dis, Results3.dis, etc. I need to change the names to Results001.dis, Results002.dis, Results003 so on and so forth. Now, Files with double digits such as Results17.dis... (3 Replies)
Discussion started by: Xterra
3 Replies

8. Shell Programming and Scripting

extract every filename containing certain string in a directory and do some commend per file

Hi, Here is my question: suppose I have files like 1990_8xdaily_atmos.nc 1991_8xdaily_atmos.nc 1992_8xdaily_atmos.nc 1993_8xdaily_atmos.nc 1990_daily_atmos.nc 1991_daily_atmos.nc 1992_daily_atmos.nc 1993_daily_atmos.nc 1990_month_atmos.nc 1991_month_atmos.nc 1992_month_atmos.nc... (1 Reply)
Discussion started by: 1988PF
1 Replies

9. 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

10. Shell Programming and Scripting

Need to understand how the line in perl program works as shell commend

I have a file with two line, one is header, the other actual value: TYPCD|ETID2|ETID|LEG ID|PTYP|PTYP SUB|TRD STATUS|CXL REASON|CACT|CACTNM|ENCD|ENC D NM|TRDR|ASDT|TRDT|MTDT|STDT|LS|SECID|SECID TYP|SECNM|PAR|STCC|MARKET PRICE|DIS MARKET PRICE|MARKET PRICE CURRENCY|SRC OF SETTLEMENT... (2 Replies)
Discussion started by: digioleg54
2 Replies
DIFF(1) 						      General Commands Manual							   DIFF(1)

NAME
diff - print differences between two files SYNOPSIS
diff [-c | -e | -C n] [-br]file1 file2 OPTIONS
-C n Produce output that contains n lines of context -b Ignore white space when comparing -c Produce output that contains three lines of context -e Produce an ed-script to convert file1 into file2 -r Apply diff recursively to files and directories of EXAMPLES
diff file1 file2 # Print differences between 2 files diff -C 0 file1 file2 # Same as above diff -C 3 file1 file2 # Output three lines of context with every diff -c file1 file2 # Same diff /etc /dev # Compares recursively the directories /etc and /dev diff passwd /etc # Compares ./passwd to /etc/passwd DESCRIPTION
the same name, when file1 and file2 are both directories" difference encountered" Diff compares two files and generates a list of lines telling how the two files differ. Lines may not be longer than 128 characters. If the two arguments on the command line are both directories, diff recursively steps through all subdirectories comparing files of the same name. If a file name is found only in one directory, a diagnostic message is written to stdout. A file that is of either block special, character special or FIFO special type, cannot be compared to any other file. On the other hand, if there is one directory and one file given on the command line, diff tries to compare the file with the same name as file in the directory directory. SEE ALSO
cdiff(1), cmp(1), comm(1), patch(1). DIFF(1)
All times are GMT -4. The time now is 11:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy