Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
Validating multiple file


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

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


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
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

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

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

if [ -d $DIRECTORY ]; then
  echo dir exists
Old 07-06-2012, 11:50 AM   #3
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
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,329

Rep: Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745
See example 7.6 here


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:14 AM.

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