Top "Bash" questions

For questions about scripts written for the Bash command shell.

How to view files in binary from bash?

I would like to view the contents of a file in the current directory, but in binary from the command …

bash shell binary
How can I pipe stderr, and not stdout?

I have a program that writes information to stdout and stderr, and I need to process the stderr with grep, …

bash grep stdout pipe stderr
Print a file, skipping the first X lines, in Bash

I have a very long file which I want to print, skipping the first 1,000,000 lines, for example. I looked into …

linux bash printing skip
Set environment variables from file of key/value pairs

TL;DR: How do I export a set of key/value pairs from a text file into the shell environment? …

bash variables environment-variables
Efficiently test if a port is open on Linux?

From a bash script how can I quickly find out whether a port 445 is open/listening on a server. I …

linux bash shell port
Remove a fixed prefix/suffix from a string in Bash

In my bash script I have a string and its prefix/suffix. I need to remove the prefix/suffix from …

bash
What does set -e mean in a bash script?

I'm studying the content of this preinst file that the script executes before that package is unpacked from its Debian …

linux bash shell sh
How to get overall CPU usage (e.g. 57%) on Linux

I am wondering how you can get the system CPU usage and present it in percent using bash, for example. …

linux bash unix cpu
How to list running screen sessions?

I have a bunch of servers, on which I run experiments using screen. The procedure is the following : ssh to …

linux bash command-line gnu-screen
if arguments is equal to this string, define a variable like this string

I am doing some bash script and now I got one variable call source and one array called samples, like …

bash scripting arguments