[prog] bash script (Wolf Rising)

cas.nixchix at gmail.com cas.nixchix at gmail.com
Sat Jan 22 14:38:23 UTC 2011


Hi I'm not an expert and most certainly am a lurker but here goes.... 
putting the exclamation point before the 'p' seems to work

sed -n '/^-/!p' $file"



On 1/22/2011 5:00 AM, programming-request at linuxchix.org wrote:
> Send Programming mailing list submissions to
> 	programming at linuxchix.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://mailman.linuxchix.org/mailman/listinfo/programming
> or, via email, send a message with subject or body 'help' to
> 	programming-request at linuxchix.org
>
> You can reach the person managing the list at
> 	programming-owner at linuxchix.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Programming digest..."
>
>
> Today's Topics:
>
>     1. bash script (Wolf Rising)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 21 Jan 2011 10:34:20 -0500
> From: Wolf Rising<wolfrising at gmail.com>
> Subject: [prog] bash script
> To: programming at linuxchix.org
> Message-ID:
> 	<AANLkTimvAj=ZkErknyLRL46Uf_N22QXc79LBz_Y-12T1 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Would anyone happen to see the syntax error in this code snippet?
>
> #push information to a file for sed to read
> ls -l /$directory>  /tmp/file
>
> #create file variable
> file="/tmp/file"
>
> case $var in
>       1) echo "These are regular files:"
>          sed -n '/^-/p' $file
>              if [ "sed -n '/^!-/p' $file" ];
>                then
>                  echo "No items found which match your criteria."
>              fi
>          ;;
>
>
>
> It's a little bash script that checks file types by the first character, I
> wanted to add an if clause but I
> seem to have an error [ "sed -n '/^!-/p' $file" ] as it skips over this an
> prints the echo statement
> whether the file type is found or not.
>
> Thanks!
>
>
> ------------------------------
>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>
>
> End of Programming Digest, Vol 74, Issue 1
> ******************************************


More information about the Programming mailing list