Re: Spliting file and save it with date...

"Thierry Blanc [email protected] [sed-users]" <[email protected]> Tue, 19 Sep 2017 10:43:17 +0200
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
the eval line is nice for instantiating variable value pairs in e.g.
config files. We don't need that here.

Adapted script, simplified.

#!/bin/bash

set -x
while read -r LINE;
do
CONTENT="$CONTENT$LINE
";

TAG="${LINE// */}"

case $TAG in
'$comment')
 echo "$CONTENT" > $date.data
 CONTENT=""
;;
 '$date' )
    date=`sed -r 's|.*"([^"]*)".*|\1|' <<< "$LINE" `
;;
esac

done < yourfile



On 19/09/17 01:30, Cameron Simpson [email protected] [sed-users] wrote:
> On 18Sep2017 16:09, Daniel Goldman <[email protected]> wrote:
>> "well, a bash script solution might be fancy here. It is slow but rather
>> easy to configure:"
>> I agree with the basic idea. Parsing the data with a bash script is a 
>> reasonable solution, and not that difficult. However, when I run the script, 
>> I get an error.
> [...]
>> $ ./script.sh
>> ./script.sh: line 11: ?php: No such file or directory
>> ./script.sh: line 11: ?php: No such file or directory
>>
>> On the face of it, seems the bash script ends up interpreting "<?php" as trying to read input from "?php" file... One simple solution would be to just get rid of those lines before processing the file, and key on the $date lines as the start of each record.
> And we're back to my core problem with this approach: even debugging the script 
> opens you up to arbitrary code execution. You just had your input file run 
> _unexpected shell commands_ !!! Using known "clean" input data.
>
> Please guys, I know it's all very cool to write compact one liners which 
> generate shell code to do the file opening, but this is asking to shoot 
> yourself in the foot.
>
> Cheers,
> Cameron Simpson <[email protected]> (formerly [email protected])
>
>
> ------------------------------------
> Posted by: Cameron Simpson <[email protected]>
> ------------------------------------
>




------------------------------------

------------------------------------

-- 

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/sed-users/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/sed-users/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/