Script not working

Smoot Carl-Mitchell smoot at tic.com
Thu Aug 13 16:37:43 UTC 2009


On Thu, 2009-08-13 at 09:00 -0700, Ray Parrish wrote:
> Hello,
> 
> I am having difficulty with a bash script. I want to loop through a file 
> line by line looking for a certain word or phrase to be on a line. When 
> I find the match, I want to load the next line into xclip.
> 
> Here is my code so far -
> 
> #!/bin/sh
> saved=" "
> while read f
> do
>     echo $f
>     echo $1
>     if  "${1}" = "${saved}" ; then
>         xclip -in -selection clipboard $f
>     else
>         saved="$f"
>     fi
> #
> done < /home/ray/.hidden/file.txt
> 

xclip is expecting to read from the *file* $f in the script and cannot
find the file.  You want to change

xclip -in -selection clipboard $f

to

echo $f | xclip -in -selection clipboard

-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list