Search Results

Search: Posts Made By: Ygor
25,737
Posted By Ygor
Or use the exit function in awk to exit...
Or use the exit function in awk to exit immediately, e.g...

awk '/pattern/ {print; count++; if (count=2000) exit}'
59,985
Posted By Ygor
Use perl... perl -pi -e...
Use perl...

perl -pi -e 's/pattern/replacement/g' file1
29,671
Posted By Ygor
What did you try? What shell are you using? This...
What did you try? What shell are you using? This is bash, but should also work in ksh...printf '%s%20s\n' $(date '+%Y%m%d') $(wc -l < a.dat) > a.ctl
136,351
Posted By Ygor
This is a script I have to send html mail with a...
This is a script I have to send html mail with a pdf attachment...#!/usr/bin/ksh

export MAILTO="spam@ebay.com"
export SUBJECT="Mail Subject"
export BODY="/tmp/email_body.html"
export...
109,173
Posted By Ygor
You should look at the manual pages for sendmail....
You should look at the manual pages for sendmail. I have only included the bare minimum to get you started. You can add headers like "To:", "Cc:", "Bcc:", "Apparently-To:", etc. This can be done...
45,820
Posted By Ygor
The Advanced Bash-Scripting Guide has some...
The Advanced Bash-Scripting Guide has some exercises (http://www.tldp.org/LDP/abs/html/exercises.html).
2,371
Posted By Ygor
Try something like...$ string1='3X' $ case...
Try something like...$ string1='3X'

$ case $string1 in [0-9][0-9]) : ;; [0-9]?) string1=${string1:0:1} ;; esac

$ echo $string1
3

$
17,564
Posted By Ygor
To execute the block, you need to have a slash /...
To execute the block, you need to have a slash / on a line of its own, after the END; line.
1,607
Posted By Ygor
Try...$ cat file1 Tom|london Tom|london ...
Try...$ cat file1
Tom|london
Tom|london
Tom|Paris
Adam|Madrid
Adam|NY
Tom|amsterdam
Tom|amsterdam
Tom|amsterdam
Tom|amsterdam

$ awk -F'|'...
12,239
Posted By Ygor
You can just use sed....sed '/PATTERN/s/ to be...
You can just use sed....sed '/PATTERN/s/ to be changed/, YEHA! to be changed/' FILENAME
37,765
Posted By Ygor
Try... echo $var|awk '{print int($1+0.5)}'
Try... echo $var|awk '{print int($1+0.5)}'
4,050
Posted By Ygor
You could also use the shell built-in variable...
You could also use the shell built-in variable $SECONDS

#!/bin/sh
START=$SECONDS
:
#script commands go here
:
END=$SECONDS
echo elapsed time is $((END-START)) seconds
43,920
Posted By Ygor
This will remove blank lines and those which only...
This will remove blank lines and those which only contain spaces...

grep -v '^ *$' $files

If you wanted to use sed, then...

sed '/^ *$/d' $files
27,610
Posted By Ygor
I think that you will have to use sendmail...
I think that you will have to use sendmail instead of mailx to send inline html, e.g....
#!/usr/bin/ksh

export MAILTO="me@work"
export CONTENT="filename.out"
export SUBJECT="Subject"
(
echo...
2,369
Posted By Ygor
In bash, variables are local to pipes. ...
In bash, variables are local to pipes.

Replacecat file | while read line
do
:
done
Withwhile read line
do
:
done < file
9,306
Posted By Ygor
I thought that file ownership is just a user ID...
I thought that file ownership is just a user ID number, which you can see using ls -ln
2,161
Posted By Ygor
See... https://www.unix.com/302098992-post2.html
See... https://www.unix.com/302098992-post2.html
1,116
Posted By Ygor
Oh I see the problem. $1 and $2 are local to...
Oh I see the problem. $1 and $2 are local to functions but you are not passing parameters to the function. Perhaps define a and b outside of the functions, e.g...$ cat sh.1
menu ()
{
echo...
6,266
Posted By Ygor
The time zone "trick" is not a reliable method of...
The time zone "trick" is not a reliable method of performing date arithmetic.

Have a look at the FAQ:...
6,266
Posted By Ygor
For datecalc, I think there are examples in the...
For datecalc, I think there are examples in the FAQ.

If you have perl, perhaps try...DATE3=$(perl -e '@f=localtime(time-(86400*7));printf "%02d%02d%02d\n",$f[5]%100,$f[4]+1,$f[3];')
2,872
Posted By Ygor
Try...$ head file[12] ==> file1 <== 999 111...
Try...$ head file[12]
==> file1 <==
999
111
222
333
111
444

==> file2 <==
555
000

$ awk '/111/&&!c++{$0=$0 s};1' s="$(<file2)" file1
999
111 555
000
222
333
111
Forum: HP-UX 09-06-2012
28,996
Posted By Ygor
Just pipe the ls through the awk command as...
Just pipe the ls through the awk command as posted by NareshN
53,199
Posted By Ygor
Try...sed -n '1p;$p' file1
Try...sed -n '1p;$p' file1
989
Posted By Ygor
This should work for any size...$ cat file1.txt ...
This should work for any size...$ cat file1.txt
var1 var2 var3 var4 var5 var6
A G A T G T
G A A A A A
A A A A A A
G A G T A T

$ awk 'NR == 1 {
split($0, var, FS)
...
2,911
Posted By Ygor
Perhaps try md5sum, e.g...md5sum -t files* | awk...
Perhaps try md5sum, e.g...md5sum -t files* | awk 'a[$1]{printf "%s and %s are the same\n",a[$1],$2;next}{a[$1]=$2}'
Showing results 1 to 25 of 98

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