Passing a bash variable to awk in a shell script
Thursday, January 03, 2013
awk
,
bash
,
shell variable
,
shell-script
0 Comments
Many a times there is a need for passing shell variables inside a shell script to awk.Thursday, January 03, 2013 awk , bash , shell variable , shell-script 0 Comments
below is the way we have to pass it and the execution is done on solaris unix:
> setenv X "hello"
> echo $X | nawk -v str="${X}" '{print str}'
hello
>
Subscribe to:
Post Comments (Atom)
Popular Posts
About The Author
I am a software programmer working in India. I usually like to blog in my free time....Read More
Labels
- array
- auto
- awk
- bash
- books
- c
- c++
- compare
- copy
- cpu
- cut
- Data Structures
- dbx
- debugger
- dtrace
- explicit
- expr
- find
- fork
- ftp
- gdb
- grep
- head
- interview-question
- isql
- java
- join
- malloc
- match
- mdb
- memory
- memory leaks
- mv
- nawk
- One liners
- paste
- pattern match
- perl
- perl script
- perl-hashes
- perldoc
- plsql
- popen
- process
- ps
- regex
- rename
- replace
- reverse
- scp
- search
- sed
- shell
- shell variable
- shell-script
- shell-scripting
- solaris
- sort
- split
- sql
- stl
- string
- sybase
- table
- tail
- tar
- truss
- unix
- vector
- vi
- vim
- xargs
Search This Blog
Blog Archive
-
2013
(50)
- November (1)
- September (2)
- July (2)
- June (4)
- May (8)
- April (4)
- March (4)
- February (4)
-
January
(21)
- Creating a child process in perl
- Explicit in c++
- Creating a hash in perl with all the regex matches
- Delete empty lines in a file
- Creating files using Awk
- List of columns in a table from SYBASE
- Executing shell command in c/c++ and parsing the ...
- Search a string in multiple files recursively
- Capturing all the regex matches into an array in perl
- Perl's equivalent of "grep -f"
- Difference between Java and c++
- Bulk rename of files in unix
- Shebang line in shell script
- Indentation in vi editor
- Splitting a string in C++
- The Definitive C++ Book Guide and List
- Modify file names containing spaces using perl
- Passing a bash variable to awk in a shell script
- Caplitalize(change to uppercase )first letter of e...
- Deleting the lines in the file from the end of a f...
- Using Join Command in Unix
Powered by Blogger.
Pages
Gallery
[フレーム]Contact Us
Popular Posts
-
I have two files File 1 contains 3 fields File 2 contains 4 fields The number of rows of File 1 is much smaller than that of File 2 I...
-
Normally while working on PL/SQL stored procedures , we use DBMS_TRACE for knowing about the values of various variables and put some print...
-
At times you need to specify different courses of action to be taken in a shell script, depending on the success or failure of a command. Th...
-
Below is a most simple command for Sorting Unix processes by highest memory usage: ps -eo pmem,pid,pcpu,rss,vsz,time,args | sort -k 1 -r ...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are released every year.Unlike many other programmin...
-
There are lot of ways where one can identify memory leaks and lots of blogs and materieals are available to help a designer to identify the...
-
This awk one-liner works for multi-column on unsorted files. Comparision is done based on 1st,2nd,3rd,4th of the first file and 1st,3rd,6th,...
-
File3 a c e File4 a 1 b 2 c 3 d 4 e 5 the one liner for comparing the first field of file4 with the first field of file3 is:...
-
In unix, if we run a process(a shell script).It will not return to the terminal untill the script ends. lets say there is a script temp.sh ...
-
Most of the time it is required that w eneed to rename the files in bulk. this can be done in many ways,Mostly people do it by writing a s...
0 comments: