-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
244 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Robbins,,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# addrs.awk --- simple mailing list program | ||
|
||
# Records are separated by blank lines. | ||
# Each line is one field. | ||
BEGIN { RS = "" ; FS = "\n" } | ||
|
||
{ | ||
print "Name is:", $1 | ||
print "Address is:", $2 | ||
print "City and State are:", $3 | ||
print "" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# run "awk -f changeFSonthefly who.txt" | ||
NR < 4 {FIELDWIDTHS = "1 1"} | ||
NR >= 4 {FS = FS} | ||
{ | ||
$0 = $0; # it's important to reload $0, otherwise change in FS is not performed | ||
print $1 ";" $2 ";" PROCINFO["FS"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Zacatek | ||
/* | ||
* ahoj | ||
* caues | ||
*/ | ||
Konec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BEGIN { | ||
FPAT = "([^,]*)|(\"[^\"]+\")" | ||
} | ||
|
||
{ | ||
print "NF = ", NF | ||
for (i = 1; i <= NF; i++) { | ||
|
||
# if (substr($i, 1, 1) == "\"") { | ||
# len = length($i) | ||
# $i = substr($i, 2, len - 2) # Get text within the two quotes | ||
# } | ||
$i = gensub(/^"(.+)"$/, "\\1", 1, $i) # remove double quotes | ||
printf("$%d = <%s>\n", i, $i) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# copies input to output | ||
# shows random line from /etc/passwd if line begins with @random | ||
BEGIN { | ||
srand() | ||
passwd = "/etc/passwd" | ||
("wc -l " passwd) | getline count # number of lines in passwd file | ||
} | ||
{ | ||
if ($1 == "@random") { | ||
line = int(count * rand()) + 1 # generate random line number | ||
tmp = "tail -" line " " passwd "|head -1" # get random line | ||
tmp | getline | ||
close(tmp) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@random | ||
bar | ||
baz | ||
@random | ||
fred | ||
joe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# gawk profile, created Tue Jun 14 20:01:00 2016 | ||
|
||
# BEGIN rule(s) | ||
|
||
BEGIN { | ||
cmd = "sort -n" | ||
ret = "12;111;Ahoj;čaues;nazdarek;drstkova" | ||
num = split(ret, pole, ";") | ||
for (id in pole) | ||
print(pole[id]) |& cmd | ||
close(cmd, "to") | ||
while ((cmd |& getline) > 0) | ||
close(cmd) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# print all lines of input files | ||
# long variant | ||
BEGIN { | ||
while (getline) | ||
print $0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# print all lines of input files | ||
# simple variant | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
// Single line comment in c source code | ||
|
||
printf("Writing comments is very useful.\n"); /* one more */ /* OK */ | ||
printf("Nazdarek"); /* jiste */ | ||
/* wov efekt */ printf("Na ja"); /* budeme | ||
hola */ printf("Jiste"); | ||
/* | ||
* Multi line comment syntax | ||
* Comments help us to understand code later easily. | ||
* Will you write comments while developing programs ? | ||
*/ | ||
|
||
printf("Good luck c programmer number %d.\n", 1); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Remove text between /* and */, inclusive | ||
{ | ||
if ((i = index($0, "/*")) != 0) { | ||
out = substr($0, 1, i - 1) # leading part of the string | ||
rest = substr($0, i + 2) # ... */ ... | ||
j = index(rest, "*/") # is */ in trailing part? | ||
if (j > 0) { | ||
rest = substr(rest, j + 2) # remove comment | ||
} else { | ||
while (j == 0) { | ||
# get more text | ||
if (getline <= 0) { | ||
print("unexpected EOF or error:", ERRNO) > "/dev/stderr" | ||
exit | ||
} | ||
# build up the line using string concatenation | ||
rest = rest $0 | ||
j = index(rest, "*/") # is */ in trailing part? | ||
if (j != 0) { | ||
rest = substr(rest, j + 2) | ||
break | ||
} | ||
} | ||
} | ||
# build up the output line using string concatenation | ||
$0 = out rest | ||
} | ||
print $0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Remove text between /* and */, inclusive | ||
# It removes even multiple occurences on line | ||
|
||
BEGIN { | ||
findleft = 1 | ||
leftmark = "/*" | ||
rightmark = "*/" | ||
} | ||
|
||
{ | ||
leftpart = "" | ||
rightpart = $0 | ||
nocomment = "" | ||
while (!findleft || (idleft = index(rightpart, leftmark)) > 0) { | ||
if (findleft) { | ||
leftpart = substr(rightpart, 1, idleft - 1) # part before comment | ||
commentpart = substr(rightpart, idleft + 2) # part after /* | ||
} | ||
else # searching for */ that was not found on previous line | ||
commentpart = rightpart | ||
|
||
nocomment = nocomment leftpart # prepare the part without comments | ||
|
||
idright = index(commentpart, rightmark) # index of */ | ||
if (idright > 0) { | ||
rightpart = substr(commentpart, idright + 2) # part after */ | ||
findleft = 1 # */ found, next time find /* | ||
} | ||
else { # */ not found | ||
findleft = 0 # find */ on the next line | ||
if (nocomment != "") | ||
print nocomment | ||
next | ||
} | ||
} | ||
|
||
# /* not found | ||
nocomment = nocomment rightpart | ||
findleft = 1 # find /* on the next line | ||
|
||
if (nocomment != "") | ||
print nocomment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Remove text between /* and */, inclusive | ||
# It removes even multiple occurences on line | ||
|
||
BEGIN { | ||
RS="\f" | ||
} | ||
|
||
{ | ||
rid = 1 | ||
orig = $0 | ||
while ((lid = index($orig, "/*")) > 0) { | ||
comment = substr($orig, lid + 2) | ||
code = code substr($orig, 1, lid - 1) | ||
rid = index(comment, "*/") + 2 | ||
$orig = substr($orig, lid + rid + 1) | ||
} | ||
print code $orig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10 | ||
11 | ||
12 | ||
13 | ||
14 | ||
15 | ||
16 | ||
17 | ||
18 | ||
19 | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" } | ||
NR > 2 { | ||
idle = $4 | ||
sub(/^ +/, "", idle) # strip leading spaces | ||
if (idle == "") | ||
idle = 0 | ||
if (idle ~ /:/) { | ||
split(idle, t, ":") | ||
idle = t[1] * 60 + t[2] | ||
} | ||
if (idle ~ /days/) | ||
idle *= 24 * 60 * 60 | ||
|
||
print $1, $2, idle | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
10:06pm up 21 days, 14:04, 23 users | ||
User tty login idle JCPU PCPU what | ||
hzuo ttyV0 8:58pm 9 5 vi p24.tex | ||
hzang ttyV3 6:37pm 50 -csh | ||
eklye ttyV5 9:53pm 7 1 em thes.tex | ||
dportein ttyV6 8:17pm 1:47 -csh | ||
gierd ttyD3 10:00pm 1 elm | ||
dave ttyD4 9:47pm 4 4 w | ||
brent ttyp0 26Jun91 4:46 26:46 4:41 bash | ||
dave ttyq4 26Jun9115days 46 46 wnewmail |