I have an awk script that I run through a bash shell in Cygwin on an NT box. I execute it as so: $>dedup.awk file
It will scan the file and remove duplicate lines and echo the unique lines to the shell. How do I set this up as a tool within Textpad? I understand how to use configure/preferences to click tools/add/program but need more instructions on the what to put in for the command and parameters. Am I supposed to put the awk.exe for the command or my awk dedup script. I want to be able to depup a file I have opened in Textpad and have the unique lines be captured to another file. The way I thought it should be setup was:
(Command) D:\Applications\Cygwin\bin\awk.exe
(Parameters) D:\Applications\Cygwin\usr\local\bin\dedup.awk -f $file
but this produced a blank file (the file has duplicate lines)
Textpad: Setting up tool/command
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Re: Textpad: Setting up tool/command
You need to setup a dos command, it will put cmd.exe in the command line automatically. This opens a command prompt window.
your parameters could then be:
awk D:\Applications\Cygwin\usr\local\bin\dedup.awk -f $file
if you really need to run in a bash shell you'll need to be more creative. I'm not a bash shell expert but you might try something like:
bash -c "awk D:\Applications\Cygwin\usr\local\bin\dedup.awk -f $file"
I tried it with a very simple example:
bash -c ls
which seemed to work.
good luck.
David.
your parameters could then be:
awk D:\Applications\Cygwin\usr\local\bin\dedup.awk -f $file
if you really need to run in a bash shell you'll need to be more creative. I'm not a bash shell expert but you might try something like:
bash -c "awk D:\Applications\Cygwin\usr\local\bin\dedup.awk -f $file"
I tried it with a very simple example:
bash -c ls
which seemed to work.
good luck.
David.
Re: Textpad: Setting up tool/command
Thanks David! The key clue you gave me was trying to run bash first and then call the awk.exe and script. FYI here is what the parameter line looks like:
D:\Applications\Cygwin\bin\bash -c "D:/Applications/Cygwin/bin/awk -f D:/Applications/Cygwin/usr/local/bin/dedup.awk $UNIXfile"
I had a typo in a previous post of the dedup.awk script. Here is the correct code:
#! /bin/awk -f
{
if (data[$0]++ == 0)
lines[++count] = $0
}
END {
for (i = 1; i <= count; i++)
print lines
}
D:\Applications\Cygwin\bin\bash -c "D:/Applications/Cygwin/bin/awk -f D:/Applications/Cygwin/usr/local/bin/dedup.awk $UNIXfile"
I had a typo in a previous post of the dedup.awk script. Here is the correct code:
#! /bin/awk -f
{
if (data[$0]++ == 0)
lines[++count] = $0
}
END {
for (i = 1; i <= count; i++)
print lines
}