Wie repariere ich SED -Befehle, die bei hoher Last extrem langsam werden?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie repariere ich SED -Befehle, die bei hoher Last extrem langsam werden?

by Anonymous » 02 Apr 2025, 20:13

Ich habe ein Bash -Skript, das eine einfache Eigenschaftendatei aufnimmt und die Werte in eine andere Datei ersetzt. (Eigenschaftsdatei ist nur Zeilen von 'foo = Bar' Typeigenschaften) < /p>

Code: Select all

INPUT=`cat $INPUT_FILE`
while read line; do
PROP_NAME=`echo $line | cut -f1 -d'='`
PROP_VALUE=`echo $line | cut -f2- -d'='`
time INPUT="$(echo "$INPUT" | sed "s\`${PROP_NAME}\b\`${PROP_VALUE}\`g")"
done 
Niedrige Last: < /p>
real  0m0.011s
user  0m0.002s
sys  0m0.004s
Normalerweise ist es keine große Sache, 0,1 Sekunden zu verlieren, aber beide Eigenschaftendateien und die Eingabedateien sind Hunderte/Tausende von Zeilen lang. Benötige ich nur mehr CPUs?

Code: Select all

$foo=bar
$hello=world
^hello=goodbye
< /code>
Beispieleingabe < /p>
This is a story about $hello. It starts at a $foo and ends in a park.

Bob said to Sally "^hello, see you soon"
< /code>
Erwartete Ergebnis < /p>
This is a story about world. It starts at a bar and ends in a park.

Bob said to Sally "goodbye, see you soon"

Top