Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Linux command: awk
(view source)
Revision as of 17:09, 7 January 2018
363 bytes added
,
17:09, 7 January 2018
no edit summary
Line 1:
Line 1:
−
Comand line text processing
+
=
Comand line text processing
=
Examples:
Examples:
<source lang="bash">
<source lang="bash">
Line 9:
Line 9:
</source>
</source>
−
Print from 3rd field till end
+
==
Print from 3rd field till end
==
<source lang="bash">
<source lang="bash">
awk '{ \
awk '{ \
Line 19:
Line 19:
== Print with condition ==
== Print with condition ==
awk '{if ($3 =="" || $4 == "" || $5 == "") print "Some score for the student",$1,"is missing";'}' student-marks
awk '{if ($3 =="" || $4 == "" || $5 == "") print "Some score for the student",$1,"is missing";'}' student-marks
+
+
== Print columns as lines ==
+
ls -lR | awk '{for(x=1;$x;++x) print $x}'
+
<nowiki>awk '{for(x=1;$x;x++)print $x}'
+
___ __ ___
+
| | |
+
| | |-----> increment x by 1 at the end of each loop.
+
| |--------> run the loop as long as there is a field number x
+
|------------> initialize x to 1</nowiki>
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version