If option statement

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If option statement
# 8  
Old 10-02-2013
Originally Posted by dannyvdberg
. . .
But for my i won't work
. . .
That's not enough. What does not work? Error msgs? Undesired output? And, why didn't you copy my proposal fragment?
# 9  
Old 10-02-2013
I'm totally lost in it now.. I tried your piece of code.

tar_gz=( $(find @etc@apache2@mods-available.tar.gz @etc@apache2@mods-enabled.tar.gz @etc@apache2@ports.conf.tar.gz @etc@apache2@sites-available.tar.gz \
@etc@apache2@sites-enabled.tar.gz) )

if [ ${#tar_gz[@]} -ne 5 ] 
        echo "file set incomplete"
        exit 1

for FN in ${tar_gz[@]} 
        if [ -f $tar_gz ]
                echo "found"
                tar -zvf $tar_gz


Want i want for this script:

Find all the 5 tar.gz files, if they're found than get a message and extract them if they're not found exit this script.
# 10  
Old 10-03-2013
for FN in ${tar_gz[@]} 
        if [ -f "$FN" ]
                echo "found"
                tar -zvf "$FN"


# 11  
Old 10-04-2013
Hello RudiC

This is my code now and it works.

FILES=`find ${CHOICE} -name @etc@apache2@*.tar.gz  -type f`

echo "Founded tar.gz files from Apache2"
echo "--------------------------------------"
echo "${FILES}"
echo "--------------------------------------"

for FILE in ${FILES}
        tar -zxf ${FILE} -C /etc/apache2
        echo "Result off tar.gz ${FILE} extract = ${RESULT}"

service apache2 reload

Thank you for helping me! I appreciate it. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

3. UNIX for Dummies Questions & Answers

What is the meaning of "-s" option in "if" statement?

Hi Guys, I'm sorry but I can't find answer for this, what is the meaning of -s option in "if" statement on unix scipting. Please see sample below: opath=/home/output for i in N1 N2 N3 N4 do echo $i if then grep $i $opath/N5_CRAI > $opath/N5_$i.crai chmod 777 $opath/N5_$i.crai ... (7 Replies)
Discussion started by: rymnd_12345
7 Replies

4. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

5. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

6. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

7. Programming

g++ and the -R option

hi everybody, can somebody tell me what -R option on g++ on solaris means : g++ -DAIX -fpic -static -o printps printps.o -L/epost2/blitz/xercesc1_1 /lib -L/oracle/OraHome/lib32/ L/epost2/blitz/lib -lxerces-c1_1 -lhmltods -lhmlt ops -lgeneric -lnotify -lutil -lclntsh `cat... (0 Replies)
Discussion started by: eternalflame
0 Replies

8. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

9. Programming

cc option

my yacc output file y.tab.c is not compiling using cc y.tab.c -ly command .possibily option flag -ly is not correct.i m using red hat linux 9.please give solutions. (4 Replies)
Discussion started by: kuldeep_bora
4 Replies

10. Shell Programming and Scripting

option in if statement

does anyone know what the -a in an if statement is referring to ex... if (6 Replies)
Discussion started by: cubs0729
6 Replies
Login or Register to Ask a Question