Search Results

Search: Posts Made By: colemar
Forum: What is on Your Mind? 01-04-2014
1,939
Posted By colemar
Quest for the most useless command
I wrote by accident:
cd .
and even hit ENTER.

Then I realized this is probably the most useless command that you can imagine. Yes, perhaps it could assert that there is still a working...
Forum: IP Networking 04-01-2010
19,927
Posted By colemar
HOWTO: Linux multihomed dns client
The Linux resolver queries all nameservers in the order they are listed in /etc/resolver.conf.
If a nameserver times out, it advances on to the following nameserver.
But, if a nameserver returns...
12,505
Posted By colemar
It is wise to not reveal the password to anybody...
It is wise to not reveal the password to anybody who is able to run a ps -ef | grep sqlplus command. Therefore:
$ORACLE_HOME/bin/sqlplus -s << SQLEND
connect $APP_USER
@$HOME/sql/your_SQL.sql...
1,342
Posted By colemar
If you are viewing the file in vi, ^[ is a...
If you are viewing the file in vi, ^[ is a representation of the character escape (ESC, 0x1b) and ESC[01;34 is a terminal command to change the color.

You have an ls command that is doing colored...
3,492
Posted By colemar
cat bigfile a b c d potter e f...
cat bigfile
a
b
c
d potter
e
f pattern
g
h
i
j

grep -n 'p.tter' bigfile
4:d potter
6:f pattern

a=$(grep -n 'p.tter' bigfile)
a=${a%%:*}
echo $a
4
1,482
Posted By colemar
p='$INSTALL_BASEPATH/onereview-5.0/resources/commo...
p='$INSTALL_BASEPATH/onereview-5.0/resources/commons-messages/commonmessages_default.properties'
p=/${p#*/}
p=${p%/*}
echo "[$p]"
[/onereview-5.0/resources/commons-messages]
1,780
Posted By colemar
cat source.txt ...
cat source.txt
1;xxxxx;xxxxxxxxxx|xxxx;xxx;aaaaaa;4#a1x;x;x;x;xxxx#a2x;x;xx;x;xxx#a3xx;xx;xxx;x;xxx#a4xx;xx;xx;x;x...
2,633
Posted By colemar
The script has many unnecessary calls to external...
The script has many unnecessary calls to external commands like sort, uniq, wc, expr...
Some blocks could be rewritten as a single call to awk. For example:

while read myline
do
echo...
1,898
Posted By colemar
gawk -F'[/: ]' ' ...
gawk -F'[/: ]' '
/^..\/..\/..../{j=strftime("%j",mktime($3" "$2" "$1" 00 00 00"))}
/^..:../{print j,$1$2,$3}
' infile > outfile
8,348
Posted By colemar
Right. In this case however >> does not hurt,...
Right. In this case however >> does not hurt, since the files are newly created.



Right. It is funny that I didn't include a close() because you originally didn't provide it.

mkdir tmp
awk...
8,348
Posted By colemar
FILENAME==s is always true since it can happen...
FILENAME==s is always true since it can happen only just after s=FILENAME.

>FILENAME is writing to the same file that awk is reading, I believe this is not a good idea. Plus, to append to a file...
8,348
Posted By colemar
This is a tough one. Could be done with awk,...
This is a tough one.

Could be done with awk, but to simplify its work I believe it would be a good idea to first combine all the files in one file in such a way that all the original information...
2,217
Posted By colemar
1,952
Posted By colemar
.Z suffix is not really a good test to ascertain...
.Z suffix is not really a good test to ascertain if a file is compressed with compress.

I believe this is better:

if [[ $(file $MYFILE) = *"compressed data"* ]]
1,919
Posted By colemar
Sounds like the file start.sh is missing the x...
Sounds like the file start.sh is missing the x mode bits.

chmod u+x start.sh

Also you should explicitly state in the first line of the script what is the interpreter program that should be...
1,488
Posted By colemar
This is not trivial. Possible solutions include...
This is not trivial.
Possible solutions include perl, ksh93, GNU date command, GNU awk.

GNU date:
last_sunday_yyyymmdd=$(date -d "-$(date +%w) days" +%Y%m%d)
day_of_run=20090523...
2,745
Posted By colemar
Also doing even the join work in awk: nawk ' ...
Also doing even the join work in awk:
nawk '
NR==FNR { c = a[$1]; a[$1] = c?c" "$2:$2; next }
{ c = a[$1]
if (c) {
split(c,b)
for (k in b) {
p = $2<b[k]?$2" "$1" "b[k]:b[k]"...
2,745
Posted By colemar
join -o 1.2 0 2.2 -1 1 -2 1 file1 file1 | nawk...
join -o 1.2 0 2.2 -1 1 -2 1 file1 file1 | nawk '!a[$3$2$1];{a[$1$2$3]++}'

This may perform better (or not) with a large file1:

join -o 1.2 0 2.2 -1 1 -2 1 file1 file1 | nawk...
8,442
Posted By colemar
It's just another way to specify some text to...
It's just another way to specify some text to send to the stdandard input.

It seems that ssh actively refuses any input from the standard input if not connected to an interactive terminal.
...
1,970
Posted By colemar
# two passes varname=$b$i eval...
# two passes
varname=$b$i
eval value=\$$varname

# one shot
eval value=\$$b$i
3,801
Posted By colemar
awk -F'[^0-9]+' '{b=b...
awk -F'[^0-9]+' '{b=b (NR>1?"|":"")($2?sprintf("%02d:%02d %02d:%02d",$2,$3,$4,$5):"")}END{print b}' yourfile.txt

If you really want 11 spaces instead of a blank field, then:

awk -F'[^0-9]+'...
2,977
Posted By colemar
result="$(small.sh ${arrayname })" ...
result="$(small.sh ${arrayname
})"
result="$(small.sh ${arrayname[@]})"
2,474
Posted By colemar
Why? $@ was there to replicate for ls the...
Why?
$@ was there to replicate for ls the arguments given to the command hls, so that you can say for example:
hls -rS /bin/*



I was using ls from Debian Linux, $5 was the size and $8 was...
2,474
Posted By colemar
More fun with awk
#!/usr/bin/ksh
ls -l $@ | awk '
/^-/ {
l = 5*log($5)
h = sprintf("%7d %-72s",$5,$8)
print "\x1B[7m" substr(h,1,l) "\x1B[27m" substr(h,l+1)
}
'

ls command with histogram of file sizes.
The...
2,436
Posted By colemar
Fun with awk
uggc://ra.jvxvcrqvn.bet/jvxv/EBG13

#!/usr/bin/awk -f

BEGIN {
for (n=0;n<26;n++) {
x=sprintf("%c",n+65); y=sprintf("%c",(n+13)%26+65)
r[x]=y; r[tolower(x)]=tolower(y)
}
}

{
b =...
Showing results 1 to 25 of 117

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