Small shell script help required


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Small shell script help required
# 1  
Old 08-06-2008
Small shell script help required

Hi Guys,

Please can some one explain me the below part of code. In this code what is the use of the line in Bold.

COPY=0
if [ -s $CONF ]; then
echo "$CONF exists and is non-empty - backing it up"
SUFFIX=`date +%Y%m%d%H%M%S`
echo "cp -p $CONF $CONF.$SUFFIX"
cp -p $CONF $CONF.$SUFFIX
[ $CLOBBER -ne 0 ] && COPY=1
else
COPY=1
fi

Regards,
Abhishek
# 2  
Old 08-06-2008
It means 'if the variable CLOBBER is not zero then set COPY=1'
# 3  
Old 08-06-2008
Ok Thanks for the help....

Regards,
Abhi
# 4  
Old 08-06-2008
you better read what && means
Operators
also read this
Test Constructs
# 5  
Old 08-06-2008
One more query......

I am trying to assign a value to a variable but getting error....

IP_ADDR=${`grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2| cut -d . -f 1-3| sed s/" "//g`}

I am using this script to grep first three octets of an IP address from a file and assign the value to IP_ADDR....but I am not able to assign the value to the variable...

Please some one help.

Regards,
Abhishek
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Small help required to create For loop

Hi, I am new to UNIX and have an issue. I need to check that whether a perticular file name exists or not. I wan to do that in loop to avoid number of IF statements. I need to check that if file10.txt exists rename that to file11.txt. if file9.txt exists rename that to file10.txt. : : if... (5 Replies)
Discussion started by: unankix
5 Replies

2. Shell Programming and Scripting

Small Help required for merging two files per line!!!

Hi Guys, Sorry to bother everyone again here, but I ran into a small problem that has been after me for some time now. I have a file called file1.txt and has following content - /folder1/fold/folder 10k /folder167fold/folder 10MB /folder2/fold/folder 10G etc.. etc.. ... (1 Reply)
Discussion started by: rockf1bull
1 Replies

3. UNIX for Dummies Questions & Answers

help needed with a small shell script!

I have a scenario where i need to look for files of these kind filename.log.0 filename.log.1 if the files are present, then no action is to be taken, if not found, then it shud create/touch files with the same name. so can anyone help constructing the script for me..appreciate ur help. ... (5 Replies)
Discussion started by: win4luv
5 Replies

4. Shell Programming and Scripting

Write a small shell script

Hello Forum members, Have a nice day. I have to write a script for the following below scenario. There are 3 applications located in home directory(ie xyz/app) which have multiple directories and files of diff format(.sh,log,other formats). Case 1: I have to find the hardcoded... (8 Replies)
Discussion started by: rajkumar_g
8 Replies

5. UNIX for Dummies Questions & Answers

A small script required!!

Hi All, I am using korn shell sun solaris 10 What i need is i have to grep one file and if there are any finding then i have set one flag. otherwise continue Please help Regards Arun (9 Replies)
Discussion started by: annyarun
9 Replies

6. Shell Programming and Scripting

shell script required...

There are two fields actually one is server name and the other one is Time. Based on time, there are 8 columns and these will be updated with the flag 1 if at all if there is any server name. Time Server name 15 to 18 18 to 21 21 to 24 00 to 03 03 to 06 06 to 09 09 to 12 Server... (3 Replies)
Discussion started by: venkatesht
3 Replies

7. Shell Programming and Scripting

Please help to debug a small shell script (maybe AWK problem)?

Hi Buddies, The following is shell scripts which was borrowed from linux box for load average check. it runs good. (this structure is simple, when load average is too high, it will send alert to user) #!/usr/bin/ksh # Set threshold for 1, 5 and 15 minture load avarage # configured for... (4 Replies)
Discussion started by: GreatJerry
4 Replies

8. Shell Programming and Scripting

Very small Shell Script Help...

The following Script takes each extension and determine what category it belongs and then moves it into a directory based on the extension. (for eg. 1.sh, 5.sh, 9.sh together; 4.csh, 120.csh, 6.csh together and 7.ksh, 2.ksh, 59.ksh together) and moves them to their respective directories viz.... (2 Replies)
Discussion started by: marconi
2 Replies

9. Shell Programming and Scripting

what is problem with this small shell script.. case statement related

Hi All, this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem. #!/bin/bash echo "Enter the character" read a case $a in )... (2 Replies)
Discussion started by: johnray31
2 Replies

10. Linux

shell script required

Hi, iam presenting the input text file format.Of this i need the character count of the number of characters present in each file.The attached file is a combination of 3 text file.each text file starts at record 1 - 34, then the next tetx file starts. What i need is the character count of each... (1 Reply)
Discussion started by: sethunath
1 Replies
Login or Register to Ask a Question