![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Stripping out extensions when file has multiple dots in name | Nemelis | Shell Programming and Scripting | 8 | 05-14-2008 05:12 AM |
| Truncate multiple file extensions | prvnrk | Shell Programming and Scripting | 12 | 04-04-2008 07:20 AM |
| batch file | ramneek | IP Networking | 1 | 11-08-2005 07:09 AM |
| File name extensions | thurrock | Shell Programming and Scripting | 2 | 11-07-2001 09:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
We are moving from an OpenVMS server to a Unix server and I have a problem with ftp'ing files.
When I ftp the VMS server from the Unix server, I need to "mget" some files, for example "mget test_file*.txt;". The semicolon is necessary because OpenVMS has multiple versions of the file (eg test_file.txt;1, test_file.txt;2, etc). When I do this i end up with the file "test_file.txt;2". I then need to convert this to remove the semicolon. I have tried various methods and have found one that works : for file in *.txt*; do noext="${file%.*}" mv "$file" "${noext#*.}.txt" done However, I have problems with this : 1. it renames ALL .txt files even if they have no ";" and version number. 2. it will only do one file extension at a time. 3. it is inefficient What I want is to say "for all files with a semicolon in the file extension, rename the file to everything to the left of the semicolon". Better yet, "give me all files matching *.txt; from theVMS server, and create them on the Unix server without the ;" Any suggestions would be appreciated. |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
Code:
for file in `ls ./*\;*`
do
mv "$file" "${file%;*}"
done
|
|
|||
|
danmero: *bling*, Useless Use of ls in Backticks.
Code:
for file in *\;*
do
mv "$file" "${file%;*}"
done
|