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

Re: Why wouldn't "stringing" of an input parameter using an array work? ...



Albretch Mueller wrote: 
>  Why would:
> 
> kate "file1_ps_-aux.txt" "file2_dmesg.txt" "file3_printenv.txt" &
> 
> kate "${_FL1}" "${_FL2}" "${_FL3}" &
> 
>  work?, but stringing the file names using a loop wouldn't?
> 
>  I need to keep somehow declaratively the files read in by kate at
> start up, so I thought of using an array:
> #
> _FL1="file1_ps_-aux.txt"; sudo ps -aux > "${_FL1}"
> _FL2="file2_dmesg.txt"; sudo dmesg > "${_FL2}"
> _FL3="file3_printenv.txt"; sudo printenv > "${_FL3}"
> 

It's going to be quoting.

Here's a readable way to do this which largely avoids the
quoting problem:

TD=`mktemp -d`
pushd $TD
_FL1="file1_ps_-aux.txt"; sudo ps -aux > "${_FL1}"
_FL2="file2_dmesg.txt"; sudo dmesg > "${_FL2}"
_FL3="file3_printenv.txt"; sudo printenv > "${_FL3}"
kate *.txt
popd
rm $TD/*
rmdir $TD


Reply to: