![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unix begginers | jao_madn | UNIX for Dummies Questions & Answers | 4 | 10-08-2007 09:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
a begginers question
hey
i'm very much new to unix i'm trying to write a script which goes through given files and checks if the files begin with # and if they are executable my problem is that when i try to check the result of my query i'm getting nada let me explain : when i write if (`file $i | grep 'executable' `=~ ?*) or if (`head -1 $i | grep '^#' ` != ``) i'm getting weird results i'm guessing my sintax is way off here... any suggestions on the proper syntax for checking if the return value of this query isn't NULL...? thanks in advance |
|
||||
|
sorry for being such a pain,
but i'm supposed to specificly check that the outcome "file filename" has the word executable in it... and i didn't quite get the (b) part - should i use it as a condition like so: if ("dd if=file name bs = 1....." == "#") (as i said...very new to unix ) |
|
||||
|
Quote:
Code:
if test -x $FILE
then
FIRSTCHARS=`dd if=$FILE bs=1 count=2`
if test "$FIRSTCHARS" = "#!"
then
echo starts with "$FIRSTCHARS"
fi
fi
Code:
file $FILENAME | grep executable >/dev/null
if test "$?" = "0"
then
echo file says its executable
fi
Last edited by porter; 01-06-2008 at 07:41 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|