Skip to content

Tag: bash

Does an argument after a redirection do anything?

Is any argument after a redirection ignored, or does it have any unintended consequences? I was surprised to find that a typo I made in my bash script made absolutely no difference because it was specified after a redirect. E.g. I expected it to complain about something like this But it doesn’t throw an…

ack outputs nothing using crontab in linux

ack outputs nothing using crontab in linux. In the crontab file (edited with sudo crontab -e): And cat /ext/test110.sh will show After cron, there are 1.t and 2.t in /ext cat 2.t will output /usr/bin/ack; However, nothing in 1.t. If I run ack “localhost” /etc/hosts > /ext/3.t in bash (4.3.30) o…

How to convert to / get RFC822 date in bash/linux?

Looking at date’s man page, I couldn’t find a standard way to convert to rfc822 (eg: from unix timestamp). I took a brief look at the spec, but I don’t know enough about the subject matter to get the format right. Is there a easy way to convert to rfc822 with standard linux terminal tools? A…

Listing files with numeric names

How do I list files that have only numeric names e.g I have tried ls -l [0-9]* but this seems to bring all file names that start with a digit and can have anything in their name after a digit. Answer First, turn on Bash’s extglob option: Then use this pattern: Read more about extended pattern matching i…

Awk in loopwith different file

I have four files and want to run a awk code on each file. But this code is not working. My code: Answer Awk can work with multiple files no need of for syntax will be like this or In your case To correct your existing code change To