LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-06-2012, 10:59 AM   #1
rameshpaul_cog
LQ Newbie
 
Registered: May 2012
Posts: 19

Rep: Reputation: 0
Validating multiple file


Hi,

It may be simple ... but am not getting a break here...Any help would be really appreciated...

I want to validate couple of variables before i execute a command

Here is the scenario

Code:
count=' ${NAME_SRC_PATH} | grep "^${name}\/$" | wc -l`
if [ $count -eq 0 ];
then
        echo "Error Creating ${name} "
        exit 1
else
        echo "Name Created."
fi
Now i want to check some 5 more src_path .. how can i chk that... ?

Say like NAME_SRC_PATH1,NAME_SRC_PATH2.NAME_SRC_PATH3,NAME_SRC_PATH4,NAME_SRC_PATH5...

the paths are declared by me only ...and if the name exists in NAME_SRC_PATH3 .. it should return name exits is 3...likewise..for all...

i understand its simple... am totally blank now... any pointer would be helpful....
 
Old 07-06-2012, 11:41 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
To check for blank variables, I usually do something simple like:

Code:
if [ x$VARIABLE == "x" ]; then
  echo blank
else
  echo not blank
fi
If you're looking to see if a directory exists then it's a bit different

Code:
if [ -d $DIRECTORY ]; then
  echo dir exists
fi
 
Old 07-06-2012, 11:50 AM   #3
rameshpaul_cog
LQ Newbie
 
Registered: May 2012
Posts: 19

Original Poster
Rep: Reputation: 0
Hi...thanks first.....

no its not directory....

i think ...that if- conidtion will work.... thanks alot....
 
Old 07-08-2012, 08:45 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
See example 7.6 here http://tldp.org/LDP/abs/html/comparison-ops.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to transfer multiple file to multiple server using public and private key sampadray81 Linux - Newbie 5 02-27-2012 01:31 PM
[SOLVED] validating mandatory column value in csv file using script sukhdip Linux - Newbie 2 01-31-2012 03:45 AM
how to open multiple windows to view multiple docx file with window 2007 installed astromoko Linux - Newbie 2 08-01-2011 09:45 PM
Combine multiple one column text file into one text file with multiple colum khairilthegreat Linux - Newbie 7 11-23-2007 02:31 PM
Validating rules file error. mike8994 Linux - Networking 0 09-05-2004 09:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration