Search Results

Search: Posts Made By: chatguy
2,578
Posted By MadeInGermany
awk '$1=="zone" { del=($2~/deletethisentry.com/)...
awk '$1=="zone" { del=($2~/deletethisentry.com/) } !del' /var/named/zones.conf
If Field#1 is "zone" then set del according to field#2 containing "deletethisentry.com"; print if del is 0.
2,578
Posted By nezabudka
sed '/delete/,/^$/d' file
sed '/delete/,/^$/d' file
2,578
Posted By RudiC
awk OK? awk '/delete/, /^}/ {next} 1' file ...
awk OK?
awk '/delete/, /^}/ {next} 1' file
zone "localhost" {
type master;
notify no;
file "db.myzone";
};


zone "keepthisentry.com" {
type master;
notify no;
file "db.myzone";
};
10,015
Posted By Yoda
Use nawk or /usr/xpg4/bin/awk instead on Solaris...
Use nawk or /usr/xpg4/bin/awk instead on Solaris or SunOS:
ifconfig lo0:5 inet6 | nawk '/inet6/{gsub(/inet6 |\/.*/,x)}1'
5,813
Posted By RudiC
I don't know how large your log files will be,...
I don't know how large your log files will be, but greping or seding them will always read them from the start, which may become serious overhead.
If you just want to know if there's a DONE...
5,813
Posted By hanson44
Yes, this is exactly what I'm suggesting. Here is...
Yes, this is exactly what I'm suggesting. Here is working code, using sed as a better way to get the part of log file to test:

LAST_LINE_WITH_DONE=`grep -n DONE log | tail -n 1 | cut -d : -f 1`...
5,813
Posted By biker
is it necessary to key off of the "DONE!" or...
is it necessary to key off of the "DONE!" or could you somehow have the script check the status of the software under test? maybe running some sort of pre-existing status command or check the...
5,813
Posted By alister
Are there no timestamps in this log file? Or...
Are there no timestamps in this log file?

Or do as you suggested and tail the file. Pipe the stream into code that exits when it matches (grep -q). Worst case, tail will linger until the next time...
5,813
Posted By hanson44
Would this work: The first time, check if...
Would this work:

The first time, check if "DONE" already exists in the log file, using grep -n and tail -n 1 to find the last line number that "DONE" occurs on.

Then use the while loop,...
9,539
Posted By chihung
xmllint is a very handy tool to work with XML...
xmllint is a very handy tool to work with XML files. Here is a foolproof way to get the ip addresss no matter how your XML file is formatted, even it is packed in one line.


echo "
setns...
9,539
Posted By fpmurphy
To get the IPv4 addresses into an array: $...
To get the IPv4 addresses into an array:

$ set -A myarray `sed -n '/ip="/s/.*ip="\(.*\)" loc.*/\1/p' infile`
$ echo ${myarray[@]}
192.168.1.101 192.168.1.117 192.168.1.154 192.168.1.159
9,539
Posted By Shell_Life
As you may have found, XML parsing can be very...
As you may have found, XML parsing can be very complex.

Each case should be treated uniquely.

As for the data sample you provided, try the code below:
sed -n '/ip="/s/.*ip="\(.*\)" loc.*/\1/p'...
1,696
Posted By bartus11
I think this should work for you:tail -f...
I think this should work for you:tail -f /var/log/logfile.log | perl -pe 's/ERROR/\e[41;1m$&\e[0m/g;s/SUCCESS/\e[42;1m$&\e[0m/g'
6,762
Posted By DGPickett
Well, signals go to all the processes, so the...
Well, signals go to all the processes, so the trap is in the tail's parent. You could open a subshell and set the trap just in there. It it is in a script, on most UNIX it is in a script-running...
1,812
Posted By Corona688
Not when using a wildcard, I think. That is done...
Not when using a wildcard, I think. That is done inside the shell, you can't feed a literal "*.gz" into tar and expect it to understand. So either you need to be in the directory, or specify the...
1,198
Posted By Scrutinizer
Another variation: FIRSTIPADDR=$(echo $VAR |...
Another variation:
FIRSTIPADDR=$(echo $VAR | awk -F'[ @]*' '{$0=$5}1')
echo $FIRSTIPADDR
or:
v=${VAR#*@}; FIRSTIPADDR=${v%% *}
echo $FIRSTIPADDR
1,198
Posted By anbu23
$ echo $VAR | sed...
$ echo $VAR | sed "s/.*@\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\\).*/\1/"
10.10.10.10
1,198
Posted By john1212
try: FIRSTIPADDR=`echo $VAR | awk '{ print...
try:
FIRSTIPADDR=`echo $VAR | awk '{ print substr($5,2) }'`
echo $FIRSTIPADDR
1,198
Posted By bartus11
TryFIRSTIPADDR=$(echo $VAR | awk...
TryFIRSTIPADDR=$(echo $VAR | awk '{sub("@","",$5);print $5}')
echo $FIRSTIPADDR
19,262
Posted By frank_rizzo
or use it inline if pkginfo TestPackage >...
or use it inline


if pkginfo TestPackage > /dev/null 2>&1
then
echo yeah
else
echo doh
fi
19,262
Posted By zaxxon
I would go for something like this: pkginfo...
I would go for something like this:

pkginfo TestPackage > /dev/null 2>&1 # we do not want any output
if [ $? = 0 ]; then
echo yeah
else
echo doh
fi


And btw, this looks...
1,559
Posted By methyl
The problem is that underscore is a valid...
The problem is that underscore is a valid character in a variable name.
The shell is substituting $NAME_test not $NAME .
Surrounding the variable name with braces is the solution and many...
1,559
Posted By radoulov
By using: cp -- "${NAME}_test.tgz"...
By using:

cp -- "${NAME}_test.tgz" "/tmp/${NAME}_test.tgz"

Or just:

cp -- "${NAME}_test.tgz" /tmp
1,583
Posted By bartus11
perl -0pe 'if (!s/\n\n$/\n/){s/$/\n/}'...
perl -0pe 'if (!s/\n\n$/\n/){s/$/\n/}' /tmp/text.txt > /tmp/text.tmp; mv /tmp/text.tmp /tmp/text.txt
3,323
Posted By agama
Assuming that the full script name is in $spath...
Assuming that the full script name is in $spath (e.g. /usr2/bin/script), then the following code in Kshell will yield the last part of the directory:


fullpath=${spath%/*} # full path of...
Showing results 1 to 25 of 26

 
All times are GMT -4. The time now is 12:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy