Help pls...Rename .dat files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help pls...Rename .dat files
# 1  
Old 02-25-2013
Help pls...Rename .dat files

Hi,

I have some .dat files in some directories , i want them to be moved to another directory by changing file names.

for ex:

Code:
cat > /ai/rcmid/feb_files/temp/temp.txt
aaa.dat
bbb.dat

Code:
rm -rf main
rm -rf a001
rm -rf a002
mkdir main
mkdir a001
mkdir a002
touch a001/aaa.dat
touch a001/bbb.dat
touch a002/aaa.dat
touch a002/bbb.dat
while read fname1
do

c=1
while [[ $c -le 2 ]]
do
  mv /ai/rcmid/feb_files/temp/a00"$c"  /ai/rcmid/feb_files/temp/main/"${fname1}_${c}"
   	
let c=c+1
done

done </ai/rcmid/feb_files/temp/temp.txt

Here i am unable to change the .dat names, the above code is creating multiple directories which is not expected. can you please help.

---------- Post updated at 03:56 PM ---------- Previous update was at 03:47 PM ----------

I need O/P as below:

Code:
cd main
ls
aaa_001.dat
aaa_002.dat
bbb_001.dat
bbb_002.dat

---------- Post updated at 05:05 PM ---------- Previous update was at 03:56 PM ----------

Pls Can any one please check and respond
# 2  
Old 02-26-2013
You did not cd, so where is this always running?

First outer loop reads aaa.dat and first inner loop has c=1, so if there is a /ai/rcmid/feb_files/temp/a001 then it moves to /ai/rcmid/feb_files/temp/main/aaa.dat_1 which is not your desired first file or dir.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute a Command in a .Dat File and use it in other Files

We have a process where we store the database password in a config file like below from where the password is picked up and used in Database Scripts ID, Password But we now have a Audit Requirement not to have the passwords in Config Files directly. We have a command which could fetch the... (2 Replies)
Discussion started by: infernalhell
2 Replies

2. Shell Programming and Scripting

How to use 'ls' command to list files like *.dat, not *.*.dat?

How to use 'ls' command to list files like *.dat, not *.*.dat (5 Replies)
Discussion started by: pmcginni777
5 Replies

3. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

4. UNIX for Dummies Questions & Answers

Pls. help with script to remove million files

Hi, one of the server, log directory was never cleaned up. We have so many files. I want to remove all the files that starts with dfr* but I get error message when I use the *. rm qfr* bash: /usr/bin/rm: Arg list too long I am trying to write this script but not working. ... (4 Replies)
Discussion started by: samnyc
4 Replies

5. OS X (Apple)

Script to process winmail.dat files in apple mail from outlook senders

Does anyone know of a way to automate the "massaging" of those STUPID winmail.dat files that come to Apple Mail extensions as a result from people sending mail from outlook clients? Specifically, something that would run when you attempt to open a winmail.dat file and auto extract and open... (2 Replies)
Discussion started by: herot
2 Replies

6. Red Hat

How to view all files on DAT tape

I'm using tar and so far so good, but how can I view ALL files without having to fast forward and rewind the tape? Let's say I append 100 files onto the tape. Having to fast forward 100 times until I find the file I want is kinda tedious. (3 Replies)
Discussion started by: sdotsen
3 Replies

7. UNIX for Dummies Questions & Answers

Using cp -r command to selectively omit *.dat files while copying a directory.

Hi all, I want to copy a directory named Ec1 to another directory named Ec2, newly created. But Ec1 has a bunch of *.dat files and many many other kinds of files. Whle creating Ec2, I selectively want to omit the *.dat files since they are huge files of the order of 100 MBs and there are... (5 Replies)
Discussion started by: d_sai_kumar
5 Replies

8. Shell Programming and Scripting

Comparing two txt files - pls help

Hi, I have some text files. I need a separate shell say 1.sh in which i can open a particular text file and compare with another txt file. For example: 1.log.txt contains apple ball cat goat 2.log.txt contains goat cat lion apple fox In my i.sh i need to write script to... (5 Replies)
Discussion started by: jisha
5 Replies

9. UNIX for Dummies Questions & Answers

Backup my files to DAT

hi guys, im using tru64 unix and i want to put my files on tapes. i have already a hp DAT storage, do you have any admin guides for backup/restore procedures for these? tnx (1 Reply)
Discussion started by: jefferson
1 Replies

10. Shell Programming and Scripting

compare two .dat files and if there is any difference pulled into a separate file

Hi, compare two .dat files and difference will be moved into separate file.if anybody having code for this please send asap. using diff command, i don't know how to write shell programming. and my first file is like this including Header and trailer 10Ç20060323Ç01(Header) 01ÇIÇbabuÇ3000 01ÇIÇbaluÇ4000... (1 Reply)
Discussion started by: kirankumar
1 Replies
Login or Register to Ask a Question