|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Unix Scripting Question
I have multiple files in one directory starting with POS. ex. POS123.date
POS345.date I want to touch each POS* file in the directory to create a 0 byte file called: POS123.date.complete POS345.date.complete What is the command to use to do this? This will be in a script and there will be multiple files in this directory beginning with POS. Bman79 |
|
#2
|
|||
|
|||
|
for file i `ls pos*`
do something whith $file done |
|
#3
|
|||
|
|||
|
Code:
for filename in /path/to/directory/POS*
do
echo $filename | grep -q "complete"
if [ $? -eq 0 ] ; then
touch "$filename".date.complete
fi
done
I'm assuming you will run this day after day, so you do not want to 'retouch' files with the name *.complete" |
|
#4
|
|||
|
|||
|
thank you jim for:
for filename in /path/to/directory/POS* i used (will no longer) for filename in `ls -options /path/to/directory/POS*` you show me, the shell can resolve it, thanks again. i don't really agree with your (xpg4)grep i propose: case $filename in *complete) continue;; esac OR case $filename in *complete*) continue;; esac the second, is the same as your grep; so my version: for filename in /path/to/directory/POS* do case $filename in *complete) continue;; esac touch $filename.date.complete done |
|
#5
|
|||
|
|||
|
Thank You. This worked!
This was very helpful.
|
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Unix Scripting Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|