On Jul 3, 2022, at 12:52 AM, David Brostoff <[email protected]> wrote:
> On Jul 2, 2022, at 9:29 PM, David Kelly <[email protected]> wrote:
>>
>> Type the command line and rather than type the input file name just drag the
>> file to the command line. Finder/Terminal will write the file's full path on
>> the command line.
>
> Thanks for the tip, but I must be doing something wrong.
>
> First I copy and paste this command:
>
> awk ‘{ print $1 >> “col-1.txt”
> print $2 >> “col-2.txt” }’ input.txt
>
> Then I drag the source file to the command line and press Enter, which
> produces this error message:
>
> awk: syntax error at source line 1
> context is
> >>> ? <<<
> missing }
> awk: bailing out at source line 1
>
> Two text files are produced, but the one named "col-1.txt" is blank and the
> "col-2.txt" has this line, repeated three times:
>
> }’ input.txt/Users/davidbrostoff/Desktop/Sample2010-2011.txt
Sorry about previously not testing it myself and trying to lead you down a
problematic path of bundling the awk script on a split command line. Some
things work in bash that don't work in csh or zsh.
This works no matter what shell:
Create an awk script file. Lets call it "script.awk" that looks like this:
{
print $1 >> "col-1.txt"
print $2 >> "col-2.txt"
}
If memory serves the leading tabs may not be necessary, but the above is
tested. The tab before first { is where one puts the line-match grep pattern
but in awk a blank matches all lines. For instance you could make the script
only split lines that contain numeric digits.
Then type "awk -f script.awk " with a trailing space then drag your file to the
command line.
Might want to delete or rename previous col-[12].txt because each invocation
will add new contents to existing files. If you run the script twice you will
get the 2nd run appended to the first.
--
David Kelly N4HHE, [email protected]
============================================================
Whom computers would destroy, they must first drive mad.
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/C5D6842A-7126-4858-B336-B3BD65DF255A%40hiwaay.net.