Visit The New, Modern Unix Linux Community

Want to do this: cp *1.dbf *2.dbf

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Want to do this: cp *1.dbf *2.dbf
# 1  
Want to do this: cp *1.dbf *2.dbf

This is not a valid command, but you get the idea: "cp *1.dbf *2.dbf"
I need to change the 1 to 2 on many file names.
Using csh. Any ideas?
# 2  
Must you use csh? This is easy with bash, for example:

# for file in *1.dbf; do cp ${file} `echo "${file}" | sed 's/1\.dbf/2\.dbf/'`; done

I don't use csh (or at least haven't for a long time) but a similar for loop using csh syntax will do the job.

# 3  
Recent versions of bash allow for parameter pattern substitution; maybe other shells do as well:
for i in *1.dbf; do echo $i "--->" ${i/1./2.}; done

# 4  
That works! No problem to use bash. Thanks for the help.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #894
Difficulty: Medium
A tr command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.
True or False?

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ArcGIS shapefile *.dbf file to ascii text

Okay, I search around and couldn't find what I needed, so here goes: I have a series of ArcGIS point shapefiles. If I open them in Excel I can save as an Excel or text file and get a 2 column list: POINTID | GRID_CODE 1 | 2.34234 2 | 4.3425 3 | 6.32456 etc... The problem is that I... (3 Replies)
Discussion started by: jbrandt1979
3 Replies

2. Shell Programming and Scripting

spilit the list of files in set ls -1 *.dbf

Dear All, Please help in this subject.. my requirement is list the files in directory and out of that list make the different set and each should set contains 10 files and assign to variable and start zipping in background. pick the second set files and same to be repeat the commands parallel. i... (3 Replies)
Discussion started by: nmadhuhb
3 Replies

3. Shell Programming and Scripting

how to read dbf file in shell script and to convert dbf file usinf shell script

Hi all, I am new to shell scripting. I have dbf file and I need to convert it into csv file. OR, can i read the fields from a .dbf file and OR seprate the records in dbf file and put into .csv or txt. Actually in the .dbf files I am getting , the numbers of fields may vary in very record and... (6 Replies)
Discussion started by: gauara
6 Replies

4. Solaris

oracle datafile *dbf

Hi ,,,, I have move an oracle db from old server to a new server ( solaris 5.9 is the operating system ) my problem is that to new server the datafile ( *.dbf ) are in a different path ..... example old : /export/home/data/blobs ........... new /oracle/data/blobs....... how i can... (3 Replies)
Discussion started by: tt155
3 Replies

5. UNIX for Advanced & Expert Users

ascii to dbf HELP!

Hi, Does anyone know of an ascii to dbf converter for sco unix? Or any flavor of unix for that matter. Thanks! Georgio (1 Reply)
Discussion started by: gseyforth
1 Replies

Featured Tech Videos