LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 10-21-2002, 10:35 AM   #1
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Rep: Reputation: 15
Question Simple console question


Hi, just playing around with the test thing

Lets say I want to check if file /bin/ls exists

This could be done with 'test -e /bin/ls'
and it should give me False or True but it gives me nothing

Really strange

Does anyone know what the problem is ?

Thanks
 
Old 10-21-2002, 11:13 AM   #2
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
test -e /bin/ls ; print $?

test does return 1 or 0 (i.e. True or False), but remember a program doesn't print what it returns - it prints what it outputs to stdout or stderr. $? holds the return value of the last command executed. Commands return 0 on success and 1 on failure, so if test returns 0 this means the file exists.

Alex

Last edited by llama_meme; 10-21-2002 at 11:16 AM.
 
Old 10-21-2002, 12:35 PM   #3
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Original Poster
Rep: Reputation: 15
Hi

test -e /bin/ls ; print $? dont work for me but

test -e /bin/ls ; echo $? did

Thanks :-)

//FredrikN
 
Old 10-21-2002, 02:29 PM   #4
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
I think

[ -e /bin/ls ] ; echo $?

should do the same, or you could just do

ls /bin | grep ls
 
  


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
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Simple console question. Moving files. The_Messiah Linux - Newbie 3 08-17-2005 11:51 PM
Simple console question. Moving files. The_Messiah Linux - General 1 08-17-2005 08:51 PM
Simple question of console and mc 3-1415 Linux - Software 1 04-05-2005 06:55 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM


All times are GMT -5. The time now is 01:38 PM.

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