[LUNI] Shell script question.
Gerald Guglielmo
gug at fnal.gov
Tue Jan 29 08:40:58 CST 2008
Hi,
You need quotes around the first instance of $file, and I don't think
you need the second one because you are piping that from the echo command.
sh-3.00$ file=.foo.barxvf
sh-3.00$ echo -en "$file" | cut -d '.' -f 2
foo
sh-3.00$
Richard Reina wrote:
> Kristian,
>
> Thanks for your reply. However, I must still be missing something.
>
> When I do:
>
> #!/bin/sh
>
> file=.foo.barxvf
>
> echo -en $file | cut -d '.' -f 2 $file
> #end
>
> I get:
>
> cut: .foo.barxvf: No such file or directory
>
> What am I missing?
>
> I know your example referred to the literal filename but I can't do that in my script as the suffix changes every time.
>
>
> Thanks again, for the help thus far.
>
> Richard
>
>
>
> Kristian Erik Hermansen <kristian.hermansen at gmail.com> wrote: On Jan 28, 2008 10:43 AM, Richard Reina wrote:
>> I've been playing around with inotify but my shell scripting
>> ignorance is getting in the way.
>>
>> ${file} is getting written with a dot "." and a wacky suffix like
>> ".yfEVx1" which causes the script to crash at line 5 with:
>>
>> cat .new_file.yfEVx1: no such file or directory. How can I capture the
>> true file name as it appears (new_file) so that cat will work?
>>
>> Pardon my ignorance. Any help would be greatly appreciated.
>
> Pass your "wacky" file name through this filter...
>
> cut -d '.' -f 2
>
> Watch...
> $ echo -en '.new_file.yfEVx1' | cut -d '.' -f 2
> new_file
--
-Jerry->
gug at fnal.gov
Pepe's Theory of everything: "Under the right circumstances, things happen."
More information about the luni
mailing list