Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Using SED to create a directory

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
0
16
CA
I have a file: 12345-6789A.prt
I would like to create a directory: 12345-6789+A/

If I have 50 similarily named files (#####-####X.prt) I would like to create 50 directories.

I think I can use sed, for example:

for file in *;
do mkdir `echo $file | sed 's/'$1'/'$2'/g'` ;
done

where $1 is "12345-6789" and $2 is "12345-6789+", but I don't know how to make $1 and $2 be what I want.

Can someone help?

Thanks,
Jeff
 
Status
Not open for further replies.
Back
Top