curl: (7) Failed to connect to localhost port 80: Connection refused

Problem

You would like to access a host set up with nginx after adding your own vhost configuration file in /etc/nginx/conf.d/myfile.smth, but you get Connection refused.

Solution

Make sure that your nginx configuration file has the .conf extension as /etc/nginx/conf.d/myfile.conf.

Copying files between two folders without overwriting existing ones in destination folder.

Problem

You would like to copy the contents of a source directory to a destination directory without overwriting existing files on the destination.

Solution

You can use

and you can also use the –dry-run option to test before running it.

Bash getting the parent folder name from a bash defined variable

Problem

You have defined a variable in a bash script (ie MY_FOLDER) but you also want to dynamically get the parent folder (ie MY_FOLDER can have multiple values).

Solution

Use the dirname as in the following

Removing a range of history lines from bash history

Problem

You would like to remove some lines from the bash history (ie using cut and paste with wrong values).

Solution

You can use the following, taken from the answer here

where start_line is the start of the lines you want to remove and no_of_lines is the number of lines you want to be removed.

Removing empty lines from text/csv file with awk in linux

Problem

You have a text file that has empty lines, and you would like to remove them.

Solution

You can use awk in linux like the following to create a new file with the empty lines removed:

Search for content in files in linux (recursively and case-independent)

Problem

You would like to find the files that contain some specific text, and would like to do it recursively (ie in a project folder), using something simpler than the find command.

Solution

You can use the following in your current top folder to search recursively, case-independent and by displaying the file number that the searched text appears, with the following: