LinuxQuestions.org
Help answer threads with 0 replies.
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 01-23-2017, 11:04 PM   #16
nodir
Member
 
Registered: May 2016
Posts: 222

Rep: Reputation: Disabled

On a side note:

Code:
if $(grep -q /dev/sdc1 /proc/mounts)
should be rather like
Code:
 if grep -q /dev/sdc1 /proc/mounts; then
assuming one wants to check if sdc1 is mounted.
if cares for the exit status of grep (success or failur), not for the output grep gives.
to put it different:
Code:
 grep root /etc/passwd; echo "exit code of grep: $?"
Code:
 grep_var=$(grep root /etc/passwd); echo "result of grep: $grep_var"
If the script relies on the stick to be mounted, i would make it exit in case the mount fails:
Code:
 mount -U 84B46F79B46F6C9C /mnt/wd || exit 1
|| also tests for the exit code, if the previous command failed, || will make exit 1 be executed (like or: either the right side of || will succeed, or the left side will be executed).
If this is too confusing (and it sure doesn't help much with the actual problem, just test for a successfull execution of mount with if-fi, and exit if mount failed).
 
  


Reply

Tags
error, input, output


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
[SOLVED] Bash scripting to find CPU info and perform action DavidDiepUSC Linux - Newbie 10 03-09-2013 04:55 AM
Script to check for text file is different and perform certain action depam Linux - Newbie 3 11-26-2012 09:54 PM
[SOLVED] Bash: Need help with an if statement to check if a file exists or not. MTAS Programming 16 10-26-2010 12:08 PM
[SOLVED] bash - check if file exists in tree hashbang#! Programming 10 01-21-2010 01:37 PM
Bash Help: Check if file exists richinsc Programming 6 01-09-2009 12:27 PM

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

All times are GMT -5. The time now is 10:47 PM.

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