Bash Script Question

Marius Gedminas marius at pov.lt
Tue Sep 28 21:55:30 UTC 2010


On Tue, Sep 28, 2010 at 11:59:43AM -0500, Linda wrote:
> It has been 20 years since I did shell scripting. I was wondering if 
> anyone could help me out so I didn't have to find my old reference manuals.
> 
> I have the following bash shell script
> 
> #!/bin/bash
> # print.sh
> # print files from the right-click context menu in Nautilus
> #place this script in ~/.gnome2/nautilus-scripts
...
> I would like to change it so it only prints pdf, ps and txt files will 
> this work.
> 
> echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | while
> read file
>    
> case "$file" in
>   '*.pdf ' | ''*.PDF')
>   '*.ps ' | ''*.PS')
>   '*.txt ' | ''*.TXT') lpr "$file"
>                               ;;
>   esac
> exit

No, but you're close.  This should work:

case "$file" in
  *.pdf|*.PDF|*.ps|*.PS|*.txt|*.TXT)
    lpr "$file"
    ;;
esac

Marius Gedminas
-- 
Just to be extra clear about this: yes, it is morally wrong for us to have
written RetchMail, and it is morally wrong for you to use it. But try it, it's
really fast!
	-- http://open.nit.ca/wiki/index.php?page=RetchMail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100929/f2985bd7/attachment.sig>


More information about the ubuntu-users mailing list