Skip to content

Get Subnet mask in Linux using bash

I am using bash to get the IP address of my machine with that script: And now I am trying to get the Subnet Mask in this type: But I have no idea how can I do that. Answer there are couple of ways to achieve this: first: to print the mask in format 255.255.255.0, you can use this: second:

How do symlinks in a host volume work in Docker containers?

My question is about what happens when you create a symlink from inside a container in a host mounted directory. It’s easiest if I just ask with an example. Assume we start a container like so. Most of the command doesn’t matter, what’s important here is the host volume mount. While in the c…

How to feed awk input from both pipe and file?

I was wondering how do I get awk to take a string from the pipe output and a file? I’ve basically have a chain of commands that eventually will spit out a string. I want to check this string against a csv file (columns separated by commas). Then, I want to find the first row in the file that contains

Using cut to remove until a delimiter from end

I have a string with many delimiters like : abcd – efgh – foobar.extension (Delimiter ‘-‘) I want to remove the So far, I have done But this does not help as it echo’s I want to be able to keep the inital part before the final delimiter(‘-‘) is found. Answer In bash y…

Circular SSH Tunnel

Is is possible to create a circular SSH Tunnel? local1 >SSH_TUNNEL> remote1 >SSH_TUNNEL> local1 On “Remote1” I create a TAR that I want to pipe to STDOUT ( – ) … can I then TAR – . | >SSH_TUNNEL> local1 ssh user@remote1 “tar -cvf – . | ssh user@local…

Combining two bash commands

If found this code which gives pi Ip address and this which sends 1.2.3.4 off to dweet.io stream How can I get the output from 1st to replace the 1.2.3.4 in second please? Answer Save the output of the first command in a variable: Btw, if your raspberrypi is running raspbian, then a much cleaner way to get th…

what is the difference between uio.h and io.h?

Sometimes I see compiler complaining about this line with fatal error: sys/io.h: No such file or directory If I simply change it to It will magically work. Can someone explain to me the difference? Why do some OSes have one but not the other? Edit: This issue happens on a Linux, not just OS X. Answer Generall…