Using "awk" with other variables from the same script
Hello all,
I'm just start using "awk" for my log processing script, actually I just use awk for grep things:
but now I have to put it into a script so that I can add more project and add to cronjob, the original script is:
log_process.sh
I searched around in internet know that need to add -v for awk, so i tried:
but error appeared: awk: VAR2=server_access_log.txt syntax error
Actually I got another errors beside this syntax error but I forgot to mark them down, I think the method I use to passing variables to awk is wrong, would you please help on advice me to use awk in a shell script, thanks a lot.
p.s. Although using grep can do the same thing, but I really want to try awk, thank you so much.
Thanks for the help guys, I think using "awk" to do the things that "grep" is a little bit stupid but I wanna try to learn more about "awk"
Now I'm gonna upgrade it to do more complicated task, my log is in /usr/local/tomcat/log/log.txt, I want to find different browsers from the log and put them in different files, e.g. find IE from the log and put IE's log in IE.txt by using awk.
I watched some tutorial, and know that I can use BEGIN & END on this task, so I tried:
browser.awk contains:
i think it should work... but it doesn't, it gives syntax error, and I'm seeking for help again ... thanks so much
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hello All,
I have embedded some expect code inside a Bash script I'm writing, but for some reason any variable I 'set' to something is
showing as empty immediately on the next line...
I haven't run into this problem before so I'm not sure what it could be...? I'm guessing it has something to... (4 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
both ksh/bash support this 2 special variables, Is there any document for reference?
1) "-" is $OLDPWD
2) "$_" is last argument of previous command. (4 Replies)
hi,
i have a file having datas like that
./a.txt
12344
12345
12346
12347
.....
.....
...
i want to save this datas to another file like that
./b.txt
12344 12345 12346 12347 ... ... ...
i think awk can make this but how? :) waiting for ur help. (3 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
My first post here...
I cannot get variables to work when using inline KSH commands on a "su" command. I have a KSH script, below, that produces my problem:
#!/usr/bin/ksh
su <user_id> <<-END
export FLD1=`echo $PWD`
pwd
echo $FLD1
echo TEST
echo $PWD
END
The script will prompt me... (3 Replies)