Register
It is currently Fri Oct 31, 2014 2:04 pm

Interactive script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Nov 12, 2009 1:55 am   

Joined: Thu Nov 12, 2009 1:51 am
Posts: 2
Greetings!
I have this simple scripts

Code:
#!/bin/bash

find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" > data_schema

find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" >> data_schema

<data.schema awk '{print NR, "inVol=" $0, "setDt=4000", "ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/"}' > data.schema


and this is the output

1 inVol=/kl1/CTT/TQI_001/330_spike/sz00/latcon1/stackmuted.dig setDt=4000 ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/
2 inVol=/kl1/CTT/TQI_001/330_spike/sz00/latcon1/stack_pimpmuted.dig setDt=4000 ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/
3 inVol=/kl1/CTT/TQI_001/330_spike/sz00/latcon1/stack_simp_muted.dig setDt=4000 ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/
4 inVol=/kl1/CTT/TQI_001/330_spike/sz00/latcon1/stack_rmuted.dig setDt=4000 ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header

Is there anyway I can make it interactive so I can just put ie directory and desired variable DT w/out editing the script manually everytime?

Somehow like this


Code:
echo "Enter the directory name"
read src
echo "Enter DT variable if any"
read DT

for file in `find $src name "*.dig"`
.....


Top
 Profile  
 PostPosted: Thu Nov 12, 2009 9:35 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 551
I'd write:
Code:
read -p 'Enter the directory name: ' SRC
read -p 'Enter DT variable if any: ' DT
FILES=($(find $SRC -type d -name "*.dig"))
for file in FILES
do
awk '{print NR, "inVol=" $0, "setDt=4000", "ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/"}' <<<\
"$file"
done > data.schema
this has not been tested, but should work.


Top
 Profile  
 PostPosted: Thu Nov 12, 2009 9:08 pm   

Joined: Thu Nov 12, 2009 1:51 am
Posts: 2
Thanks alot for your reply
The scripts works fine but there`s alil bit need to be fix

Here`s the output
1 inVol=FILES setDt=4000 ebcdicHdr=/kl1/CTT/TQI_001/410_segy/130header/

The invol output should be
/kl1/CTT/TQI_001/330_spike/sz00/latcon1/stackmuted.dig

and seem i cant debug this script,sorry still newb here

Thanks


Top
 Profile  
 PostPosted: Thu Nov 12, 2009 10:19 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 551
ya, sorry, I forgot something
Code:
for file in ${FILES[@]}; do
...
done


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP