LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-18-2010, 10:12 AM   #1
Arenlor
LQ Newbie
 
Registered: Feb 2010
Location: /milky_way/sol/terra/na/us/pa
Distribution: Debian
Posts: 11

Rep: Reputation: 0
Silencing the line "echo test > test/test.txt" in a shell script


I tried surrounding it with set +v and set -v but that did not do what I want. It always echo's test to stdout along with the file. It's line 15 below:
Code:
#!/bin/bash
echo "Testing Floppy..."
mkdir test
if [ ! -d test ]
  then
    echo "Problem creating directory."
    exit 1
fi
touch test/test.txt
if [ ! -f test/test.txt ]
  then
    echo "Problem creating file."
    exit 1
fi
echo test > test/test.txt
if ! cat test/test.txt | grep -e test
  then
    echo "Problem writing to file."
    exit 1
fi
rm test/test.txt
if [ -f test/test.txt ]
  then
    echo "Problem deleting file."
    exit 1
fi
rm -r test
if [ -d test ]
  then
    echo "Problem deleting directory."
    exit 1
fi
if [ -a test/test.txt -o -a test ]
  then
    echo "Curiouser and curiouser. Things are FUBAR."
    exit 1
fi
echo "No problems, floppy drive is good!"
Heh yes, floppies.
 
Old 06-18-2010, 11:01 AM   #2
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 330

Rep: Reputation: 140Reputation: 140
It's grep which needs to be silenced. Try
Code:
if ! cat test/test.txt | grep -q -e test
 
1 members found this post helpful.
Old 06-18-2010, 02:37 PM   #3
Arenlor
LQ Newbie
 
Registered: Feb 2010
Location: /milky_way/sol/terra/na/us/pa
Distribution: Debian
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks, and that's why I always post full source, never know if I actually know what a problem is.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does [if test "/usr/local/bin/php" = '@'php_bin'@'; then] test for zhjim Programming 3 11-02-2009 03:33 AM
How to write a simple BASH script to "test if have folowing files, than delete."? hocheetiong Programming 10 10-01-2009 01:17 PM
PHP 5.2.6 "make test" zend test failures mlnutt Linux - Server 0 05-07-2008 03:25 PM
any software to test proxies as the "proxy hunter" on windows platform? chamberlain Linux - Networking 0 05-10-2005 08:42 PM
echo "test" | rmdir g00ral Linux - General 5 05-15-2004 02:20 AM


All times are GMT -5. The time now is 12:35 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration