An AWK program consists of a sequence of pattern-action statements (and optional function definitions)
The pattern is evaluated and if the result is true the action statements are executed.
If no pattern is not specified, the default value is true so all records are selected and the actions are allways executed.
For example the following code prints all input records converted to lowercase :
If the action statements are not specified the dafault is print the input record.
For example, the following code prints all input records containing the string "OK" :
In your code there are two sequences of pattern-action
Your awk command merge all records (all records are printed without record separator because ORS="")
I still could not understand about the 'pattern value' or 'pattern space' concept. What happens if we change 1 as 2 in the above awk command?
The pattern is an expression that is evaluated for each record. If the result is true the action statements are executed.
If the result of the evaluation is a string or a number, the empty string "" and the number zero are considered to be false, all other values are true.
So the patterns 1 and 2 gives the same result that is true.
well i have some doubts about the use of this commands:
my first doubt is to know if there is a way to execute a awk program from a file? (now i do copy paste, i copy the script of a notepad on the terminal and then i press enter, but i want to put this scripts in some folder and execute them)... (3 Replies)
Hello,
I'm new to HP-UX and I'm not sure about some concepts related to resizing fs's under this OS.
First of all I'm only asking about resizing ONLINE, it means, without having to umount the fs nor rebooting, etc.
Q1. I've read that in order to resize a fs online there are 2 requirements:... (3 Replies)
Hi,
I am having the following doubts on awk. Please clarify for me.
a) What does it mean?
awk '$1=$1' and how does it change if I append FS="" to the above code?
b) What if I use awk -vFS="\n" (i.e) setting (input) field separator to newline char, then what will be the value of $0,... (6 Replies)
Hi everyone,
I read some shell script code,then I have some issue.
the following code.
let "t1 = ((5 + 3, 7 - 1, 15 - 4))"
echo "t1 = $t1"
t1=11
Here t1 is set to the result of the last operation.why? (3 Replies)
Hi,
I have 3 doubts which I posted it here.
Doubt 1:
I have a file containing data:
22 -73 89 10
99 21 15 -77
23 63 -80 91
-22 65 28 97
I am trying to print the fields in the reverse order and replace every field by its absolute (positive) value
(ie.) I am looking for output:
10... (8 Replies)
Hi ,
I m beginner for Unix and i want to use FIFO in my 2 Scripts . I want 1 script to read data from FIFO and other will write into FIFO.
Despite reading so many articles/posts i am still unable sunchronize my scripts.
My doubts are
1> Do We require both scripts as daemons to use... (0 Replies)
Hi All,
I am tring to set a shedule for cron to execute my script in every 15 min, n want a mail alert on my mail id if cron fails to get data as input for my script, how can i set that?
Thanks in advance
Subin (1 Reply)