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

"Thierry Blanc [email protected] [sed-users]" <[email protected]> Mon, 18 Sep 2017 22:06:12 +0200
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
the bug comes from  the eval line

eval $(sed 's|^\$||;s|\s*||g' <<< "$LINE" )

first, I used the <?php  line to trigger  writing the file but then the
last lines are never printed. So I changed it to $comment.
Now the eval line tries to execute  <?php  ...

With this addition the error is ignored: 
     eval $(sed 's|^\$||;s|\s*||g' <<< "$LINE" ) 2>/dev/null  #
instantiates the

or - as Daniel suggested - preprocessing the file and deleting the <?php
lines will eliminate the error.



On 18/09/17 18:09, [email protected] [sed-users] 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.
>  
>
>  $ cat script.sh
> #!/bin/bash
>  while read -r LINE;
> do
> CONTENT="$CONTENT$LINE";
>  if [[ "${LINE:0:8}" == '$comment' ]]; then
>  echo "$CONTENT" > $date.data
>  CONTENT=""
> else
>     eval $(sed 's|^\$||;s|\s*||g' <<< "$LINE" )
> fi
> done < thephpfile
>
>  
>
>  $ cat thephpfile
> <?php
> $date     = "2017-07-23";
> $time     = "23:59";
> $dummy    = "EOD";
> <?php
> $date     = "2017-07-24";
> $time     = "23:59";
> $dummy    = "1125";
>
>  
>
>  $ ./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.
>  
>
>  Daniel
>  
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
> Posted by: [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/