[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Avoiding a shebang to call awk
From: |
goncholden |
Subject: |
Re: Avoiding a shebang to call awk |
Date: |
Wed, 22 Feb 2023 17:18:05 +0000 |
------- Original Message -------
On Wednesday, February 22nd, 2023 at 12:20 AM, Greg Wooledge
<greg@wooledge.org> wrote:
> On Tue, Feb 21, 2023 at 07:24:23AM +0000, goncholden wrote:
>
> > I have make an awk file named "tool.awk". But I want to use its name
> > "tool" rather than having to call awk directly.
> >
> > Originally I had a shebang, namely "#!/bin/awk -f" in the file "tool.awk".
>
>
> This is the preferred approach. Simply rename the file from "tool.awk"
> to "tool", make sure the directory in which it lives is in your PATH,
> chmod +x if you haven't already, and you're all set.
>
> > I have removed the awk shebang from the file and added a bash function
> >
> > tool ()
> > {
> > local epath="${HOME}/Opstk/bin//opcon"
> > awk -f "${epath}"/tool.awk "${@:--}"
> > }
>
>
> This seems like a bad idea to me. Now, any time you want to do
> maintenance work on your tool, you have to look in two places. Also,
> your tool can't be used by anybody but you, and then only if you start
> with an interactive shell. You can't run it from a cron job, for example,
> or do something like "find . -type f -exec tool {} +".
>
> If you really want "tool.awk" to retain that horrible name,
Do people customarily not care that the tool is an awk script ?
I know that for bash, extensions are not used; but was not aware
that awk scripts are treated the same way.
> and to live
> in a directory which is not in PATH, then the third choice is to leave
> it where it is, named what it is, but create a symbolic link from a
> directory that's in PATH. For example,
>
> mkdir -p ~/bin; ln -s ~/Opstk/bin/opcon/tool.awk ~/bin/tool
>
> Ensure $HOME/bin is in your PATH, and you should be good to go.
- Avoiding a shebang to call awk, goncholden, 2023/02/20
- Re: Avoiding a shebang to call awk, alex xmb ratchev, 2023/02/21
- Re: Avoiding a shebang to call awk, goncholden, 2023/02/21
- Re: Avoiding a shebang to call awk, alex xmb ratchev, 2023/02/21
- Re: Avoiding a shebang to call awk, Greg Wooledge, 2023/02/21
- Re: Avoiding a shebang to call awk,
goncholden <=
- Re: Avoiding a shebang to call awk, Dennis Williamson, 2023/02/22
- Re: Avoiding a shebang to call awk, Greg Wooledge, 2023/02/22
- Re: Avoiding a shebang to call awk, goncholden, 2023/02/22
- Re: Avoiding a shebang to call awk, Alan D. Salewski, 2023/02/23