[plug] bash script help needed

Daniel Axtens danielax at gmail.com
Sun Sep 11 14:45:56 WST 2011


s/$f{filename}/${filename}/

-- d

On 11/09/2011, at 2:29 PM, Chris Griffin wrote:

> 
> 
> On Sun, Sep 11, 2011 at 1:18 PM, Daniel Pittman <daniel at rimspace.net> wrote:
> On Sat, Sep 10, 2011 at 22:15, Chris Griffin <griffinster at gmail.com> wrote:
> 
> > I have a large collection of special binary log files that I need to export
> > to ascii format.
> > This system has a utility to do this but it will only take one file name at
> > a time, no wild carding.
> >
> > Like:   exportlog -i input-filename -o output-filename
> >
> > the file names all look like:  2011-05-19_235900.log
> >
> > the date part for this lot will all start with 2011 but the rest of the date
> > and time fields can and do vary.
> > Could someone please help out with a bash script to do this, I can easily
> > put all the names into a text file if necessary.
> 
> All of them?  Easy.
> 
> ] for filename in *.log; do echo exportlog -i "$f{filename}" -o
> "${filename/.log/.text}"; done
> 
> See the bash manual for the details on the text substitution I did
> during variable expansion on output.  (Searching for '##' or '%%' is
> easier than searching for the forward slash, in the documentation,
> FWIW).
> 
> Put whatever pattern into the '*.log' bit you want.
> 
> Daniel
> --
> ♲ Made with 100 percent post-consumer electrons
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership
> 
> 
> Maybe not quite right?
> 
> 
> [root at server01]# for filename in *.log; do echo exportlog -i "$f{filename}" -o "${filename/.log/.text}"; done
> exportlog -i {filename} -o 2011-05-19_235900.text
> exportlog -i {filename} -o 2011-05-20_235900.text
> exportlog -i {filename} -o 2011-05-21_235900.text
> exportlog -i {filename} -o 2011-05-22_235900.text
> exportlog -i {filename} -o 2011-05-23_235900.text
> exportlog -i {filename} -o 2011-05-24_235900.text
> exportlog -i {filename} -o 2011-05-25_235900.text
> exportlog -i {filename} -o 2011-05-26_235900.text
> exportlog -i {filename} -o 2011-05-27_235900.text
> exportlog -i {filename} -o 2011-05-28_235900.text
> exportlog -i {filename} -o 2011-05-29_235900.text
> exportlog -i {filename} -o 2011-05-30_235900.text
> exportlog -i {filename} -o 2011-05-31_235900.text
> [root at server01]#
> 
> 
> 
> 
> 
> 
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership




More information about the plug mailing list