Sponsored Content
Top Forums Shell Programming and Scripting [bash] Check if variable is set or blank Post 302179663 by era on Friday 28th of March 2008 09:42:00 AM
Old 03-28-2008
Code:
case $path in '') echo not set;; *) echo is set;; esac

If you want to distinguish between not set and set but empty, have a look at the ${var-value} and ${var:-value} construct.

As long as you are not quoting $path, you don't need to make things conditional, though.. Your code should work already. (On the other hand, you properly ought to put $path in double quotes.)

PS. You are extracting into tarlist.txt, but using tarlist without the .txt. Also the cat | awk is a Useless Use of Cat. Google for that phrase.

Last edited by era; 03-28-2008 at 10:44 AM.. Reason: P.S.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check if variable is set in script

I want to check to see if a variable is set - and if not set it to something ie. variable name test I want to check if $test is set then if there is nothing set against this currently - then set it to 0 Whats the best / shortest way of doing this in a script? (3 Replies)
Discussion started by: frustrated1
3 Replies

2. Shell Programming and Scripting

How to check if two variable are empty strings at once? (bash)

I need to check if $1 or $2 are empty before continuing but I don't know if bash has any logic of the sort. This is what I'm looking for - except that "and" doesn't seem to work. if and ;then ... Thank you! :D (4 Replies)
Discussion started by: ph0enix
4 Replies

3. Shell Programming and Scripting

how to check the variable values is blank

HI , I have to check the values of variable is blank or not. exm : ###test test1 var=`cate filename | head -1 | cut -c1-3` I need to check the first three character of 1st line . if it is blank .then exit or we need to process . Thanks in advance . (2 Replies)
Discussion started by: julirani
2 Replies

4. Shell Programming and Scripting

Bash : Check aphanumeric content in variable

Hello everyone, I'm trying the best way to implement a check on a variable ... in particular I need to assess the content of characters and numbers , I tried on various manuals bash scripting but I could not figure out how to do ... any help? (3 Replies)
Discussion started by: ionral
3 Replies

5. Shell Programming and Scripting

BASH - set specific user variable via string operators

Apologies for the utter triviality of this question, but we all have to start somewhere! I've also tried searching but this question is pretty vague so I didn't (a) really know what to search for or (b) get many relevant hits to what I did search for. Anyway, I'm in the process of self-teaching... (1 Reply)
Discussion started by: u5j84
1 Replies

6. Shell Programming and Scripting

bash variable (set via awk+sed) not working as expected

Hi! Been working on a script and I've been having a problem. I've finally narrowed it down to this variable I'm setting: servername=$(awk -v FS=\/ '{ print $7 } blah.txt | sed 's\/./-/g' | awk -v FS=\- '{print $1}')" This will essentially pare down a line like this: ... (7 Replies)
Discussion started by: creativedynamo
7 Replies

7. Shell Programming and Scripting

Bash script set command to a variable

Hi, Will following set up work in bash script? I've got errors if assigning following binary command to a variable. But on the other hand, COMMAND="ls" works. Any explanation please? How can I assign binary command to a variable COMMAND then I can just call ${COMMAND}? COMMAND="rsync"... (3 Replies)
Discussion started by: hce
3 Replies

8. Shell Programming and Scripting

Bash question: working with an array of previously set variable strings

while i've used arrays to work with variables, i've never used them to loop through a set of strings and wanted to ask the community for some feedback or assistance. let me be specific. here's my code: # URL port Variables port2195=`nc -z $url2195 2195` port2196=`nc -z $url2196 2196`... (5 Replies)
Discussion started by: hungryd
5 Replies

9. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

10. Shell Programming and Scripting

How do i check if all parameters are set in bash?

Hi, I have 4 parameters passed to my shell and i validate if all four are entered using the following snippet: if then echo "Not entered" else echo "entered" fi I get the following output as 'Not entered even when i enter the values for all prompts. Please advise. Thanks. (5 Replies)
Discussion started by: Jesshelle David
5 Replies
c-icap(8)						      System Manager's Manual							 c-icap(8)

NAME
c-icap - ICAP filtering server SYNOPSIS
c-icap [ -f config-file ] [ -N ] [ -d debug-level ] [ -D ] DESCRIPTION
c-icap is an implementation of an ICAP server. It can be used with HTTP proxies that support the ICAP protocol. Most of the comercial HTTP proxies must support ICAP pcotocol. OPTIONS
-f config-file Specify the configuration file -N Do not run as daemon -d level Specify the debug level -D Print debug info to stdout FILES
/etc/c-icap/c-icap.conf The main configuration file /etc/c-icap/c-icap.magic In this file defined the types of files and the groups of file types. /var/run/c-icap.pid By default c-icap writes its pid in this file. The path of this file can changed using the PidFile configuration parameter in the c- icap.conf file /var/run/c-icap.ctl The commands socket. This file used to send commands to the icap server from command line. For information about implemented com- mands look below in the "Implemented commands" sub-section NOTES
Implemented commands Currently the following commands are implemented: stop The c-icap will shutdown reconfigure The service will reread the config file without the need to stop and restart the c-icap server. The services will be reinitialized Services and modules can define their own commands. Examples: To reconfigure c-icap: echo -n "reconfigure" > /var/run/c-icap.ctl Lookup tables Lookup tables are simple read-only databases. A lookup table can defined in c-icap.conf file using the form: type:path where the type is the type of lookup table and path is the extra information required to use the table (e.g. file path). Currently the fol- lowing lookup table types defined internally by c-icap: file Simple text file databases. The database records are stored in text files in the form: key[: value1, value2 ...] example path definition: file:/path/to/the/file.txt hash Similar to file lookup tables but c-icap uses fast hashes for searching. example path definition: hash:/path/to/the/file.txt regex Similar to the file lookup tables but the keys are regular expressions in the form /regex/flags where flags are 'i' to ignore case or nothing. example regex lookup table data: /^[a-m].*/i: group1 /^[n-z].*/i: group2 example path definition: regex:/path/to/the/file.txt Runtime information Someone can retrieve runtime information using the info service. The information includes bytes received and transmited, active services, information about service usage and many other. The information provided in HTML and text format. Example: Retrieve runtime information from command line: c-icap-client -i localhost -s "info?view=text" -req "a_url" SEE ALSO
c-icap-client(8) c-icap-stretch(8) c-icap-config(8) c-icap-libicapapi-config(8) c-icap-mkbdb(8) BUGS
Many... AUTHOR
Tsantilas Christos c_icap 0.1.6 c-icap(8)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy