tagged [shell]

Is there a way to 'uniq' by column?

Is there a way to 'uniq' by column? I have a .csv file like this: I have to remove duplicate e-mails (the entire line) from the file (i.e.

20 Jun at 10:44

find: missing argument to -exec

find: missing argument to -exec I was helped out today with a command, but it doesn't seem to be working. This is the command: The shell returns ``` find: missing argument to `-exec' ``` What I am bas...

19 Jun at 03:59

Sorting data based on second column of a file

Sorting data based on second column of a file I have a file of 2 columns and `n` number of rows. column1 contains `names` and column2 `age`. I want to sort the content of this file in ascending order ...

17 Jun at 08:27

How to convert a string to lower case in Bash

How to convert a string to lower case in Bash Is there a way in [bash](/questions/tagged/bash) to convert a string into a lower case string? For example, if I have: I want to convert it to:

8 Jun at 14:9

How to sort a file in-place?

How to sort a file in-place? When we use the `sort file` command, the file shows its contents in a sorted way. What if I don't want to get any output on stdout, but in the input file instead?

6 Jun at 09:51

Difference between single and double quotes in Bash

Difference between single and double quotes in Bash In Bash, what are the differences between single quotes (`''`) and double quotes (`""`)?

How to retrieve absolute path given relative

How to retrieve absolute path given relative Is there a command to retrieve the absolute path given a relative path? For example I want $line to contain the absolute path of each file in dir `./etc/`

24 May at 13:13

Timeout a command in bash without unnecessary delay

Timeout a command in bash without unnecessary delay [This answer](https://stackoverflow.com/questions/601543#637753) to [Command line command to auto-kill a command after a certain amount of time](htt...

23 May at 17:49

Convert line endings

Convert line endings I have been using `d2u` to convert line endings. After installing Puppy Linux I noticed that it does not come with `d2u`, but `dos2unix`. Then I noticed that Ubuntu is missing bot...

22 May at 20:59

Grep 'binary file matches'. How to get normal grep output?

Grep 'binary file matches'. How to get normal grep output? I've got a grep script that searches through a directory recursively. However the results I get are the following. Notice there are found mat...

20 May at 07:24

Running script upon login in mac OS X

Running script upon login in mac OS X I am wondering if anyone is able to help me out with getting a shell (.sh) program to automatically run whenever I log in to my account on my computer. I am runni...

How to check the exit status using an 'if' statement

How to check the exit status using an 'if' statement What would be the best way to check the in an `if` statement in order to echo a specific output? I'm thinking of it being: The issue I am also havi...

How to represent multiple conditions in a shell if statement?

How to represent multiple conditions in a shell if statement? I want to represent multiple conditions like this: but when I execute the script, it shows ``` syntax error at line 15: `[' unexpected, ``...

26 Jan at 19:12

I get "dquote>" as a result of executing a program in linux shell

I get "dquote>" as a result of executing a program in linux shell When I execute a script in a Linux shell, I get this output: What does this mean?

25 Jan at 17:53

Portable way to get file size (in bytes) in the shell

Portable way to get file size (in bytes) in the shell On Linux, I use `stat --format="%s" FILE`, but the [Solaris](https://en.wikipedia.org/wiki/Solaris_%28operating_system%29) machine I have access t...

20 Jan at 21:25

Reading a space-delimited string into an array in Bash

Reading a space-delimited string into an array in Bash I have a variable which contains a space-delimited string: I want to split that string with space as a delimiter and store the result in an array...

3 Jan at 18:45

Simulating ENTER keypress in bash script

Simulating ENTER keypress in bash script I've created a really simple bash script that runs a few commands. one of these commands needs user input during runtime. i.e it asks the user "do you want to ...

27 Dec at 15:23

What is the purpose of the : (colon) GNU Bash builtin?

What is the purpose of the : (colon) GNU Bash builtin? What is the purpose of a command that does nothing, being little more than a comment leader, but is actually a shell builtin in and of itself? It...

21 Dec at 15:56

Variables as commands in Bash scripts

Variables as commands in Bash scripts I am writing a very simple Bash script that [tars](https://en.wikipedia.org/wiki/Tar_%28computing%29) a given directory, encrypts the output of that, and then spl...

3 Dec at 04:5

How can I execute a command stored in a variable?

How can I execute a command stored in a variable? What is the correct way to call some command stored in variable? Are there any differences between 1 and 2?

3 Dec at 03:21

Shell command to find lines common in two files

Shell command to find lines common in two files I'm sure I once found a shell command which could print the common lines from two or more files. What is its name? It was much simpler than [diff](https...

30 Nov at 16:10

Rearrange columns using cut

Rearrange columns using cut I am having a file in the following format I want the columns to be rearranged. I tried below command > cut -f2,1 file.txt The command doesn't reorder the columns. Any idea...

27 Nov at 13:13

Difference between sh and Bash

Difference between sh and Bash When writing shell programs, we often use `/bin/sh` and `/bin/bash`. I usually use `bash`, but I don't know what's the difference between them. What's main difference be...

25 Oct at 19:20

How can I debug a Bash script?

How can I debug a Bash script? Is there a way to debug a Bash script? E.g., something that prints a sort of an execution log, like "calling line 1", "calling line 2", etc.

25 Oct at 17:30

Shell: How to call one shell script from another shell script?

Shell: How to call one shell script from another shell script? I have two shell scripts, `a.sh` and `b.sh`. How can I call `b.sh` from within the shell script `a.sh`?

22 Oct at 12:51