Pass variables to awk
with the -v
flag.
x=3
A=`echo $A|awk -v y=$x '{print y}'`
echo $A
More Related Contents:
- shell – remove numbers from a string column [closed]
- How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?
- How to select lines between two marker patterns which may occur multiple times with awk/sed
- How to use multiple arguments for awk with a shebang (i.e. #!)?
- How can I shuffle the lines of a text file on the Unix command line or in a shell script?
- How to get the second column from command output?
- Do a tail -F until matching a pattern
- Trim leading and trailing spaces from a string in awk
- How can I pass variables from awk to a shell command?
- How to add text at the end of each line in unix
- Awk replace a column with its hash value
- How to print 5 consecutive lines after a pattern in file using awk [duplicate]
- How to mkdir only if a directory does not already exist?
- How to delete duplicate lines in a file without sorting it in Unix
- How to pass command line arguments to a shell alias? [duplicate]
- How do I kill background processes / jobs when my shell script exits?
- sed whole word search and replace
- How can I quickly sum all numbers in a file?
- Meaning of $? (dollar question mark) in shell scripts
- What is /dev/null 2>&1?
- Compare two files line by line and generate the difference in another file
- How to download GitHub Release from private repo using command line
- How to input a path with a white space?
- Compare a string using sh shell
- Make xargs handle filenames that contain spaces
- How to assign the output of a command to a Makefile variable
- Block Comments in a Shell Script
- Emacs shell scripts – how to put initial options into the script?
- Which terminal command to get just IP address and nothing else?
- how do I use the grep –include option for multiple file types?