I can’t seem to get jq to behave “normally” in a shell pipeline. For example: $ curl -s https://api.github.com/users/octocat/repos | jq | cat results in jq simply printing out...
find . -type d can be used to find all directories below some start point. But it returns the current directory (.) too, which may be undesired. How can...
I’ve seen Bash scripts test for a non-zero length string in two different ways. Most scripts use the -n option: #!/bin/bash # With the -n option if [ -n...
I’m executing a script connecting via password-less SSH on a remote host. I want to set a timeout, so that if the remote host is taking an infinite time...
Given a list of files in files.txt, I can get a list of their sizes like this: cat files.txt | xargs ls -l | cut -c 23-30 which produces...
I have a file which contains several thousand numbers, each on it’s own line: 34 42 11 6 2 99 ... I’m looking to write a script which will...
I have a .csv file like this: stack2@example.com,2009-11-27 01:05:47.893000000,example.net,127.0.0.1 overflow@example.com,2009-11-27 00:58:29.793000000,example.net,255.255.255.0 overflow@example.com,2009-11-27 00:58:29.646465785,example.net,256.255.255.0 ... I have to remove duplicate e-mails (the entire line) from the file (i.e. one of...
What’s wrong with the following code? name="$filename | cut -f1 -d".'' As is, I get the literal string $filename | cut -f1 -d'.', but if I remove the quotes...
I’m looking for a simple way to find the length of the longest line in a file. Ideally, it would be a simple bash shell command instead of a...
I have a script that uses sh shell. I get an error in the line that uses the source command. It seems source is not included in my sh...