Conversation
ynonp
left a comment
There was a problem hiding this comment.
Good work. Still remained ex 4
| Answer: | ||
|
|
||
|
|
||
| cat /etc/shells |awk 'BEGIN{ORS="n\n"};1' |
|
|
||
| Answer: | ||
|
|
||
| cat /etc/shells |awk '{sub(/^/, ">")};1' |
| 3. Write an awk one-liner to swap the first and last words in the output of "help cd" | ||
|
|
||
| 4. The command /sbin/ifconfig prints information about network interfaces on the machine. A sample output is provided in the file "ifconfig.sample", and looks like this: | ||
| help cd |awk '{tmp=$1;$1=$NF;$NF=tmp;print}' |
|
|
||
|
|
||
|
|
||
| I don't have such file, can I use something else similar (can you tell me which?)? No newline at end of file |
There was a problem hiding this comment.
You can take the above text and copy it into a file, or run /sbin/ifconfig > config.txt to get the info into a file named config.txt
There was a problem hiding this comment.
Hi Ynon
I copied manually, but I don't what was the order in original file, and I don't know which pattern I need to look for, I can't know how the lines start..
There was a problem hiding this comment.
Hi Yulia,
The file consists of blocks, each looks more or less like this:
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
inet6 fe80::3270:cbed:df94:e32d%utun0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
The first line in a block starts with a word (an interface name) and all other lines begin with spaces. So for example this awk program counts how many blocks are in the file:
/^[a-z]/ {
blocks++
}
END {
print "Input had " blocks " blocks"
}
Take it as a starter and try to proceed from here. We'll solve it together on our next skype talk
|
|
||
|
|
||
|
|
||
| I don't have such file, can I use something else similar (can you tell me which?)? No newline at end of file |
There was a problem hiding this comment.
Hi Yulia,
The file consists of blocks, each looks more or less like this:
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
inet6 fe80::3270:cbed:df94:e32d%utun0 prefixlen 64 scopeid 0xa
nd6 options=201<PERFORMNUD,DAD>
The first line in a block starts with a word (an interface name) and all other lines begin with spaces. So for example this awk program counts how many blocks are in the file:
/^[a-z]/ {
blocks++
}
END {
print "Input had " blocks " blocks"
}
Take it as a starter and try to proceed from here. We'll solve it together on our next skype talk
No description provided.