How can I grep complex strings in variables?

if echo “$long_str” | grep -q “$shrt_str”;then echo “found” fi or echo “$long_str” | grep -q “$shrt_str” && echo “found” || echo “not found” But since you are using bash shell, then use shell internals. No need to call external commands shrt_str=”guide” case “$long_str” in *”$shrt_str”* ) echo “Found”;; * ) echo “Not found”;; esac

How to display only different rows using diff (bash)

a.txt: 1;john;125;3 1;tom;56;2 2;jack;10;5 b.txt: 1;john;125;3 1;tom;58;2 2;jack;10;5 Use comm: comm -13 a.txt b.txt 1;tom;58;2 The command line options to comm are pretty straight-forward: -1 suppress column 1 (lines unique to FILE1) -2 suppress column 2 (lines unique to FILE2) -3 suppress column 3 (lines that appear in both files)

echo multiple lines into a file

cat >> /path/to/existingFile.text<< EOF some text line 1 some text line 2 some text line 3 EOF switch cat >> to cat > to create a file instead of append cat > /path/to/newFile.text<< EOF some text line 1 some text line 2 some text line 3 EOF

Downloading all the files in a directory with cURL

If you’re not bound to curl, you might want to use wget in recursive mode but restricting it to one level of recursion, try the following; wget –no-verbose –no-parent –recursive –level=1 \ –no-directories –user=login –password=pass ftp://ftp.myftpsite.com/ –no-parent : Do not ever ascend to the parent directory when retrieving recursively. –level=depth : Specify recursion maximum depth … Read more

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