Re: Unix Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 4, 2004 08:42 am, Cupp Michael E Contr AFRL/DIB wrote:
> The scipt was the command line shown below.
>
>
>
> I have received a suggestion from Chris P. (THANKS, Chris) to use the perl
> script shown below - the problem is that my a.lst as used for input is
> formatted like this:
>
> "/path/to/file/file name.doc"
>
> "/path/to/file/file name.doc"
>
> "/path/to/file/file name.doc"
>
> "/path/to/file/file name.doc"
>
> "/path/to/file/file name.doc"
>
>
>
>
>
> The problem with my a.lst is that after the closing ", there may or may not
> be trailing white space.  If there is, it's not allowing the match, and
> therefore the compare fails.
>
>
>
>
>
> Any ideas how to get perl to ignore white space after the closing " or how
> I can strip this off the end.  (BUT NOT OUT OF THE MIDDLE - some of my file
> names in the a.lst are file ::SPACE:: ::SPACE:: :SPACE:: name.doc - or
> similar.
>
>
>
>
>
> Thanks,
>
> M
>

Hi,

This works as a bash script or at the command line.

If you don't care about the quotes around the names, this will remove the 
trailing whitespace on each line, plus removes the empty lines:
egrep -v "^$" a.lst | awk -F\" '{print $2}'

if you want the quotes, this puts them back:
egrep -v "^$" test.lst|awk -F\" '{print $2}'|sed -e s/^/\"/|sed -e s/$/\"/

-- 
Pete Nesbitt, rhce


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux