Suppose we have a file where each line a number, and we want to the get stat of these numbers on the command line.
If Python is installed in the system, we can use the following command:
cat data.log | python3 -c "import fileinput as FI,statistics as STAT; i = [float(l.strip()) for l in FI.input()]; print('min:', min(i), ' max: ', max(i), ' avg: ', STAT.mean(i), ' median: ', STAT.median(i))"We can also use jq to calculate the stat:
jq -s min data.txtjq -s max data.txtjq -s add/length data.txtRef:
I edit the .bash_profileand update the PATH variable wrongly, something
like this:
export PATH="/some/path"After sourcing this file, all my commands fails. This is because the system
relies on PATH variable to find the suitable executable to run.
However, we can always run an executable with its absolute path, so the remedy
is to use vim to edit .bash_profile:
/usr/bin/vim ~/.bash_profileRef:
apt search --names-only patternpattern supports regular expressions. For example, to search package starting
with a man:
apt search --name ^manRef:
I connect to a remote server via my ssh client. I noticed that after even a few minutes of inactivity, I was forced log out, and saw the following message:
timed out waiting for input: auto-logout
It turns out bash a feature to log out the user using the TMOUT env variable.
For example, TMOUT=3600 will force user to log out after waiting 3600 seconds
for user input (but no input is coming). Set TMOUT to 0 will disable this
feature.
Ref:
To find which package provides a certain file, we can use dpkg command:
dpkg -S /path/to/fileFor example dpkg -S /usr/lib/python3/dist-packages/uno.py shows the following
message:
python3-uno: /usr/lib/python3/dist-packages/uno.py
We can also use apt-file to find which package a file belongs to:
apt update && apt instal apt-file
apt-file update
apt-file search /path/to/fileTo find what file a package contains, we can to this Ubuntu packages site
and search a package. In the package detail info page, we can click the [list of files] to get the files contained in a certain release for an architecture
(see here for an example).
Ref:
Suppose we have a file where each line a number, and we want to the get stat of these numbers on the command line.
If Python is installed in the system, we can use the following command:
cat data.log | python3 -c "import fileinput as FI,statistics as STAT; i = [float(l.strip()) for l in FI.input()]; print('min:', min(i), ' max: ', max(i), ' avg: ', STAT.mean(i), ' median: ', STAT.median(i))"We can also use jq to calculate the stat:
jq -s min data.txtjq -s max data.txtjq -s add/length data.txtRef:
I edit the .bash_profileand update the PATH variable wrongly, something
like this:
export PATH="/some/path"After sourcing this file, all my commands fails. This is because the system
relies on PATH variable to find the suitable executable to run.
However, we can always run an executable with its absolute path, so the remedy
is to use vim to edit .bash_profile:
/usr/bin/vim ~/.bash_profileRef:
apt search --names-only patternpattern supports regular expressions. For example, to search package starting
with a man:
apt search --name ^manRef:
I connect to a remote server via my ssh client. I noticed that after even a few minutes of inactivity, I was forced log out, and saw the following message:
timed out waiting for input: auto-logout
It turns out bash a feature to log out the user using the TMOUT env variable.
For example, TMOUT=3600 will force user to log out after waiting 3600 seconds
for user input (but no input is coming). Set TMOUT to 0 will disable this
feature.
Ref:
To find which package provides a certain file, we can use dpkg command:
dpkg -S /path/to/fileFor example dpkg -S /usr/lib/python3/dist-packages/uno.py shows the following
message:
python3-uno: /usr/lib/python3/dist-packages/uno.py
We can also use apt-file to find which package a file belongs to:
apt update && apt instal apt-file
apt-file update
apt-file search /path/to/fileTo find what file a package contains, we can to this Ubuntu packages site
and search a package. In the package detail info page, we can click the [list of files] to get the files contained in a certain release for an architecture
(see here for an example).
Ref: