Most Popular
1500 questions
231
votes
5 answers
date command --iso-8601 option
This answer and comments mention --rfc-3339 and a "hidden" --iso-8601 option that I have used for a long time and now seems to be undocumented.
When did that option documentation get removed from the --help text?
Will the option go away anytime…

Angelo
- 2,319
230
votes
6 answers
How can I populate a file with random data?
How can I create a new file and fill it with 1 Gigabyte worth of random data? I need this to test some software.
I would prefer to use /dev/random or /dev/urandom.

Stefan Lasiewski
- 19,754
- 24
- 70
- 85
229
votes
3 answers
Are there naming conventions for variables in shell scripts?
Most languages have naming conventions for variables, the most common style I see in shell scripts is MY_VARIABLE=foo. Is this the convention or is it only for global variables? What about variables local to the script?

Garrett Hall
- 5,281
228
votes
4 answers
What does <<< mean?
What does <<< mean? Here is an example:
$ sed 's/a/b/g' <<< "aaa"
bbb
Is it something general that works with more Linux commands?
It looks like it's feeding the sed program with the string aaa, but isn't << or < usually used for that?

Daniel Jonsson
- 2,435
228
votes
5 answers
Delete files older than X days +
I have found the command to delete files older than 5 days in a folder
find /path/to/files* -mtime +5 -exec rm {} \;
But how do I also do this for subdirectories in that folder?

Teddy77
- 2,983
227
votes
19 answers
mount: wrong fs type, bad option, bad superblock
I added a new hard drive (/dev/sdb) to Ubuntu Server 16, ran parted /dev/sdb mklabel gpt and sudo parted /dev/sdb mkpart primary ext4 0G 1074GB. All went fine. Then I tried to mount the drive
mkdir /mnt/storage2
mount /dev/sdb1 /mnt/storage2
It…

Eli Korvigo
- 2,393
227
votes
12 answers
How to remove duplicate lines inside a text file?
A huge (up to 2 GiB) text file of mine contains about 100 exact duplicates of every line in it (useless in my case, as the file is a CSV-like data table).
What I need is to remove all the repetitions while (preferably, but this can be sacrificed for…

Ivan
- 17,708
227
votes
7 answers
Pass the output of previous command to next as an argument
I've a command that outputs data to stdout (command1 -p=aaa -v=bbb -i=4).
The output line can have the following value:
rate (10%) - name: value - 10Kbps
I want to grep that output in order to store that 'rate' (I guess pipe will be useful…

Paul
- 2,271
226
votes
7 answers
Using sed to find and replace complex string (preferrably with regex)
I have a file with the following contents:
and I need to make a script that changes the "name" in the first line to "something", the…

Harry Muscle
- 2,527
- 2
- 13
- 8
226
votes
6 answers
Can I redirect output to a log file and background a process at the same time?
Can I redirect output to a log file and a background process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to…

djangofan
- 4,147
226
votes
6 answers
remove particular characters from a variable using bash
I want to parse a variable (in my case it's development kit version) to make it dot(.) free. If version='2.3.3', desired output is 233.
I tried as below, but it requires . to be replaced with another character giving me 2_3_3. It would have been…

prayagupa
- 4,897
225
votes
8 answers
How to debug a bash script?
I'm having some problems with some scripts in bash, about errors and unexpected behaviors. I would like to investigate the causes of the problems so I can apply fixes. Is there a way I can turn some kind of "debug-mode" for bash, to get more…

Braiam
- 35,991
224
votes
22 answers
Simple command line HTTP server
I have a script which generates a daily report which I want to serve to the so called general public. The problem is I don't want to add to my headaches maintance of a HTTP server (e.g. Apache) with all the configurations and security…

Cid
- 2,455
- 2
- 15
- 6
224
votes
10 answers
How to copy-merge two directories?
I have two directories images and images2 with this structure in Linux:
/images/ad
/images/fe
/images/foo
... and other 4000 folders
and the other is like:
/images2/ad
/images2/fe
/images2/foo
... and other 4000 folders
Each of these…

ssierral
- 2,343
224
votes
14 answers
How to determine Linux kernel architecture?
uname -m gives i686 and uname -m gives i686 i386 output in Red Hat Enterprise Linux Server release 5.4 (Tikanga) machine. I need to install Oracle Database 10g Release 2 on that machine. So, how can I decide whether kernel architecture is 32bit or…

user2914
- 2,661