How to check whether a variable is empty or contains some value?
hi,
i want to check whether a a variable contains some value or is empty in a shell script. so if the variable contains some value i want to do some job and if the variable doesnt contain any value then i need to skip that job.
here is a sample script
read_filenames.sh contains
so, when i run the script without passing any argument, variable "FILE" should contain "s1.txt". so the output should be
but when i pass an argument to the script, then the variable "FILE" should contain the argument value. so the output should be
currently i am using the above code, but if i dnt pass any argument to the script. the output is
i read somewhere that
checks whether the variable is empty or not. but i dnt think that its doing that job. can anyone tell how can i do the above.
Hi,
I am simply trying to check if the variable is empty in the code below but it isn;t working. Anything that I might have missed here
#Check if values in job card are not empty
title=`cat $filename | grep "TITLE:" | cut -d ":" -f3`
if ]
then
echo "10:Title Empty" ":Fail">> $rptfile... (13 Replies)
Hello
So i have that script collection, in which i have a single script to create a configuration file.
In there, i have multiple occourences of something like this:
prj_title=$(tui-read "What is the TITLE? ($prj_name):")
] && prj_title="${prj_name/_/ }"
They all work as expected, if... (5 Replies)
I am reading from a file and executing the jobs with/without parameters as the job requires.
File
job1 R
job2
job3 Y 123
if
then
<job>.ksh
else
<job>.ksh $params
fi
This works fine if the line read from the file has parameters
it executes like job1.ksh R
But for... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
1.pls tell me the command for checking whether a given directory is empty or not .
2. can i check what is the... (1 Reply)
1.pls tell me the command for checking whether a given directory is empty or not .
2. can i check what is the last copied item in a directory .
and i yes , i want to move that last copied item in another directory .
pls help me with shell code for these two tasks
thanks (1 Reply)
How to check the variable is empty or not?
aaa=" "
how to check aaa variable is empty or just spacing?
If only spacing inside.. it will asume it is empty.
some are 6 spacing, or 8 spacing.. as long as variable is empty with spacing..
anyone can help me? (2 Replies)
I have the list of users in user.log, under each user folder there is sub1 folder is there. i want to check whether sub1 is empty or not, if it is empty i have to skip that user user folder and iterate next user folders. i have the sample code,its not giving not proper results.
while read line... (8 Replies)
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)
Hi Masters.....
I have problem !!!
I need to check number of records in a file and if it is zero or file is empty i need to do some task.
if ; then
echo "File s empty"
else
echo "Not empty"
fi
so how to check this condition.
I used wc -l < filename.txt => 1 for zero records
same result... (1 Reply)