Search Results

Search: Posts Made By: kumaran_5555
1,186
Posted By kumaran_5555
You should pass using -v option of awk as below ...
You should pass using -v option of awk as below

x=100
awk -v fromShellX=$x 'BEGIN{print fromShellX}' /dev/null


in your case modifiy as

awk -v a=$a,b=$b '$1>=a&&$1<=b {print...
1,347
Posted By kumaran_5555
Code for @joeyg logFile=$1 while [ 1 ] ...
Code for @joeyg
logFile=$1

while [ 1 ]
do
curr=`wc -l $logFile`
if [ "$curr" != "$prev" ]
then
echo "Command to execute"
fi
prev=$curr
sleep 1

done


If you are looking for...
12,486
Posted By kumaran_5555
This code should work for you If your...
This code should work for you

If your seperator is pipe instead of comma use replace the dot with pipe inside -F"[-,:. ]"


awk -F"[-,:. ]" '

BEGIN{
min_date="99999999"...
Forum: Programming 06-14-2011
3,342
Posted By kumaran_5555
compile your program with -g option and then...
compile your program with -g option and then execute, gdb.

I think you have posted only the one function, the problem could be even at the callee side, how the return value is being used there.
...
2,059
Posted By kumaran_5555
This works, make sure you have two columns after...
This works, make sure you have two columns after pic to avoid bad results,


awk '{for(i=1;i<=NF;i++){if($i=="PIC"){print $(i-1) $(i+1) $(i+2)}}} ' test.txt
2,476
Posted By kumaran_5555
Here is the output i have got, using solaris with...
Here is the output i have got, using solaris with nawk. Can you check are we on the same page.
user@tonga> (/home/user) $ echo $a $b $f
2 1 test.txt
user@tonga> (/home/user) $ cat test.txt
TABLE1...
2,476
Posted By kumaran_5555
Try this, awk -v v1=${POSITIONS_CASE5[${j}]}-v...
Try this,
awk -v v1=${POSITIONS_CASE5[${j}]}-v v2=${B}-v v3=file02.dat '{if(NR!=v1 ){print;next}system("head -"v2" "v3"|tail -1")}' ${TMPFILE}1 > ${TMPFILE}2
2,476
Posted By kumaran_5555
the below line is wrong, awk '{if(NR!=v1...
the below line is wrong,
awk '{if(NR!=v1 ){print;next}system("head -v2 v3|tail -1")}' v1=${POSITIONS_CASE5[${j}]} v2=${B} v3=file02.dat Instead of this, try this one

awk -v...
2,476
Posted By kumaran_5555
awk '{if(NR!=5){print;next}system("head -4...
awk '{if(NR!=5){print;next}system("head -4 file2|tail -1")}' file1
5,141
Posted By kumaran_5555
See by executing `wc -w text.txt` you are taking...
See by executing `wc -w text.txt` you are taking all word count in one go, then why are you using loop again.


maintain a variable to hold the line number and increment it each time inside the...
12,693
Posted By kumaran_5555
Try this user@tioman> (/home/user) $ cat...
Try this

user@tioman> (/home/user) $ cat test.sh
#!/bin/bash


filename="tmp.txt"

sort -n $1 >$filename


rows=`wc -l $filename|cut -d' ' -f1`
q2=`echo "($rows+1)/2" |bc`

q1=`echo...
5,141
Posted By kumaran_5555
To calculate how many lines you can use, wc...
To calculate how many lines you can use,

wc -l filename.txt

To calulcate how many words /line,

awk '{print NR NF}' filename
Forum: Ubuntu 06-03-2011
3,278
Posted By kumaran_5555
Please post such questions under Shell Scripting...
Please post such questions under Shell Scripting Forum. You will receive faster and may be better replies.
Forum: Ubuntu 06-03-2011
3,278
Posted By kumaran_5555
Hope this is what you are looking for ...
Hope this is what you are looking for
cgi@tioman> (/home/cgi) $ awk '{if(NR==1){print}else{for(i=1;i<=NF;i++){ printf "%s\t",$i ;if($i==0){printf "\n"; next} }}}' test.txt

Bh1 Bh2 Bh3 Bh4...
3,547
Posted By kumaran_5555
user@host> (/home/user) $ a=10 user@host>...
user@host> (/home/user) $ a=10
user@host> (/home/user) $ vi test.sh
user@host> (/home/user) $
user@host> (/home/user) $
user@host> (/home/user) $ ./test.sh

user@host> (/home/user) $ echo $a...
3,547
Posted By kumaran_5555
It is working fine for me.Please check whether...
It is working fine for me.Please check whether your IP is correct and try to FTP manually for that IP.

user@host2> (/home/user) $ cat test.sh
#!/bin/bash
function upload(){
ftp -inv...
3,547
Posted By kumaran_5555
function upload(){ ftp -inv $hostname <<EOF ...
function upload(){
ftp -inv $hostname <<EOF
user $user_name $pass_word
put $file_name
bye
EOF
}
This will work. You wrote the function wrong.
3,547
Posted By kumaran_5555
you have to use ftp -inv $hostname ...
you have to use


ftp -inv $hostname
user $user_name $pass_word
7,183
Posted By kumaran_5555
Can you whether the following part is working...
Can you whether the following part is working fine at your prompt.
I couldn't check that part as sshcmd isn't installed in my pc.

sshcmd -u ${vtier[$i]} -s ${vtier[$i]} df -k . | awk '{ print $5...
8,695
Posted By kumaran_5555
You have to identify a condition to make sure...
You have to identify a condition to make sure that process.sh has completed its function. Once that is done, you can star the process.sh in background using & at the end instead of just executing it....
8,852
Posted By kumaran_5555
find /home/user/c_test/ -type l |while read link;...
find /home/user/c_test/ -type l |while read link; do
> b=`basename $link`
> d=`dirname $link`
> cp $link $d/temp
> rm $link
> mv $d/temp $link


This worked for me, I was trying to copy the...
1,212
Posted By kumaran_5555
If you want the new record to be in the same...
If you want the new record to be in the same line, then you can use awk to do that. or few head and tail commands with line number will help.

I am giving a simple example with awk here,

...
1,212
Posted By kumaran_5555
I think as per your code, it seems that the strID...
I think as per your code, it seems that the strID is unique inside the recodedatabase file, i.e. we will have only one record having strID.

In this case, if you aren't bothered about the record...
1,475
Posted By kumaran_5555
$ awk -F\:...
$ awk -F\: '{key=substr($0,0,20);gsub(/\"/,"");arr[key]=arr[key]$NF;} END{for (k in arr) printf "%s:\"%s\"\n", k,arr[k]}' file.txt
10:04:56:201:id_0002:"RaZ."
10:02:23:125:id_0001:"A entry was...
1,345
Posted By kumaran_5555
Here you go awk...
Here you go
awk 'FNR==NR{tarif[$1]=$2;next}{cust[$1] += ($2 * tarif[$3])} END{ for (i in cust) print i,cust[i]}' file2.txt
666666661 53.98
666666662 56.1
666666663 10.71
666666664 44.46...
Showing results 1 to 25 of 49

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