Michael Lazin via plug on 13 Sep 2020 12:17:34 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Awk *language*: was Win Subsystem for Linux2 broken


You can do the same thing with the cut command but I tend to use awk the same way you do here all the time.  Sadly I should know how to do this in Powershell but can't think of it right now.

On Thu, Sep 10, 2020, 12:11 PM Rich Freeman via plug <plug@lists.phillylinux.org> wrote:
On Thu, Sep 10, 2020 at 12:01 PM Walt Mankowski via plug
<plug@lists.phillylinux.org> wrote:
>
> I used to still use awk for splitting files since the syntax was a bit
> simpler than Perl, but cut(1) does the simple cases even more simply,
> and for anything else I use `perl -a`.

Main thing I do with awk is use it to pull one field out of a record.

Stuff like:
zfs list -t snapshot -r offline1/storage | awk '{ print $1}' | tail -n
+2 | xargs -n 1 zfs destroy

This pulls up a list of snapshots, grabs just the first field of each,
strips the headers, then deletes each one.

Is there an easier way to pull one field (not necessarily the first)
out of a list?

--
Rich
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug