help-bash
[Top][All Lists]
Advanced

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

Searching inside files in a script


From: Khan Smith
Subject: Searching inside files in a script
Date: Wed, 13 Oct 2021 03:51:43 +0200

   Sent: Wednesday, October 13, 2021 at 1:39 AM
   From: "Alex fxmbsw7 Ratchev" <fxmbsw7@gmail.com>
   To: "Khan Smith" <khansmith@mail.com>
   Cc: "Tapani Tarvainen" <bash@tapanitarvainen.fi>, "help-bash"
   <help-bash@gnu.org>
   Subject: Re: Searching inside files in a script
   unset IFS ; t=( ) t+=( $EPOCHREALTIME ) ; sleep 1 ; t+=( $EPOCHREALTIME
   )

   d=( $( gawk -v RS='[ \n]' '{ if ( ! t ) t = $1 ; else { print $1 - t ;
   t = $1 } }' <<<${t[@]} ) ) ; declare -p d

   declare -a d=([0]="1.01743")

   On Wed, Oct 13, 2021, 00:59 Khan Smith <[1]khansmith@mail.com> wrote:

        I am running my script by sourcing it from my .bashrc.  But the
        distribution uses bash version 4.4.20.
        Have installed bash version 5.1.8 which gets installed in
        /usr/local/bin/
        Can one install bash version 5.1.8 so it is the dafaulh or do I
     run the
        risk of having the OS apply an
        update to its own built-in Bash package?
        Sent: Tuesday, October 12, 2021 at 8:17 PM
        From: "Tapani Tarvainen" <[2]bash@tapanitarvainen.fi>
        To: [3]help-bash@gnu.org
        Subject: Re: Searching inside files in a script
        On Tue, Oct 12, 2021 at 09:42:11PM +0200, Khan Smith
        ([4]khansmith@mail.com) wrote:
        > [1][1][1][5]https://mywiki.wooledge.org/BashFAQ/032
        >
        > That is too complicated for me. I have
        >
        > grep -r "${isufx[@]}" -e "$ptrn" -- "${fdir[@]}"

        Try this:



        TIMEFORMAT='%R'

        tim=$( { time grep -r "${isufx[@]}" -e "$ptrn" -- "${fdir[@]}"
        >/dev/null; } 2>&1)



        TIMEFORMAT can also contain %U for user time or %S for system
     time
        (and some other stuff as well, see bash man page for details).
        If you wish to save the grep output, redirect it to a file rather
     than
        /dev/null.



   Wonderful, many you.

References

   1. mailto:khansmith@mail.com
   2. mailto:bash@tapanitarvainen.fi
   3. mailto:help-bash@gnu.org
   4. mailto:khansmith@mail.com
   5. https://mywiki.wooledge.org/BashFAQ/032


reply via email to

[Prev in Thread] Current Thread [Next in Thread]