Difference between sh and Bash

What is sh? sh (or the Shell Command Language) is a programming language described by the POSIX standard. It has many implementations (ksh88, Dash, …). Bash can also be considered an implementation of sh (see below). Because sh is a specification, not an implementation, /bin/sh is a symlink (or a hard link) to an actual … Read more

How do I use shell variables in an awk script?

#Getting shell variables into awk may be done in several ways. Some are better than others. This should cover most of them. If you have a comment, please leave below.                                                                                    v1.5 Using -v (The best way, most portable) Use the -v option: (P.S. use a space after -v or it will be less portable. E.g., awk … Read more

How do I set a variable to the output of a command in Bash?

In addition to backticks `command`, command substitution can be done with $(command) or “$(command)”, which I find easier to read, and allows for nesting. OUTPUT=$(ls -1) echo “${OUTPUT}” MULTILINE=$(ls \ -1) echo “${MULTILINE}” Quoting (“) does matter to preserve multi-line variable values; it is optional on the right-hand side of an assignment, as word splitting … Read more

how to find a regular expression of specific string

EDIT: As OP mentioned in case any de is empty with respective id then print an hyphen, then try following. awk ‘ BEGIN{ OFS=”\t” print “ID\t\tDE” } /ID/{ if(id){ print id,de?de:”-” id=de=”” } id=$2 next } /DE/{ $1=”” sub(/^ +/,””) de=$0 } END{ if(id){ print id,de?de:”-” } }’ Input_file Could you please try following. awk … Read more

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