How does “cat

The cat <<EOF syntax is very useful when working with multi-line text in Bash, eg. when assigning multi-line string to a shell variable, file or a pipe. Examples of cat <<EOF syntax usage in Bash: 1. Assign multi-line string to a shell variable $ sql=$(cat <<EOF SELECT foo, bar FROM db WHERE foo=’baz’ EOF ) … Read more

How can I exclude directories from grep -R?

Recent versions of GNU Grep (>= 2.5.2) provide: –exclude-dir=dir which excludes directories matching the pattern dir from recursive directory searches. So you can do: grep -R –exclude-dir=node_modules ‘some pattern’ /path/to/search For a bit more information regarding syntax and usage see The GNU man page for File and Directory Selection A related StackOverflow answer Use grep … Read more

Recursively counting files in a Linux directory

This should work: find DIR_NAME -type f | wc -l Explanation: -type f to include only files. | (and not ¦) redirects find command’s standard output to wc command’s standard input. wc (short for word count) counts newlines, words and bytes on its input (docs). -l to count just newlines. Notes: Replace DIR_NAME with . … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)