I have some bash script where I get values of variable, that I would like use in awk. Does it possible include whole awk (like it possible with bash script files) file in bash e.g.:
#!/bin/sh var1=$1 source myawk.sh and myawk.sh:
print $1; Bash and awk are different languages, each with their own interpreter of the same name. The tiny sample you show is stripped down too far to make much sense:
#!/bin/sh and the other using the extension .sh. Obviously the shell can read shell script, and the command to do so is called . in Bourne shell (or source in csh and bash). set command; in awk, it's from a parsed input line). The two tools are often used in tandem, as the shell is better at combining separate programs and awk is better at reformatting tabular or structured text. It was so common that a whole language evolved to combine the tasks; Perl's roots are as a combination of shell, awk and sed.
If you just wanted to pass a variable from the shell script into an awk script, use -v. The man page is your friend.
ls -di . $PWD .. ../. /. / and compare the inode numbers. There's a . everywhere.first of all, if you're writing bash don't use #!/bin/sh that will put you in compatibility mode which is only necessarly if you're writing for portability (and then you have to adhere to the POSIX normative).
now regarding your question you just have to run awk from inside your bash script, like this:
#!/bin/bash var1=$1 awk -f myawk.sh also you should use .awk as extension I guess.
Or, many ppl do sth like this:
#!/bin/env bash #Bash things start ... var1=$1 #Bash things stop #Awk things start, #may use pipes or variable to interact with bash awk -v V1=var1 ' #AWK program, can even include awk scripts here. ' #Bash things I suggest this page here by Bruce Barnett:
http://www.grymoire.com/Unix/Awk.html#uh-3
You can also use double quote to make use of shell's extract feature but it is confusing.
Personally I just try to avoid those fancy gnu additions of bash or awk and make my scripts ksh+(n)awk compatible.
As an hardcore AWK user, I soon realized that doing the following was really a huge help :
#Content of bashrcexport AWK_REPO=~/bin/AWK.awk extension.awk -f $AWK_REPO/myScript.awk $file export PATH=${AWK_REPO}:${PATH})myScript.awk $file
bashandawk? It's called Perl :P Seriously now, I am not too sure what you're asking... What are you trying to do?