Ask a Question related to FreeBSD, Design and Development.

  1. #1

    Default awk print

    I'm using awk to parse a directory listing. I was hoping there is a
    way to tell awk to print from $2 - to the end of the columns
    available.

    find ./ -name '*stuff' | awk '{FS="/" print $3---'}

    the $3-- I want to mean -- print from col 3 to the end.

    Any awk pros?

    --
    David Bear
    phone: 480-965-8257
    fax: 480-965-9189
    College of Public Programs/ASU
    Wilson Hall 232
    Tempe, AZ 85287-0803
    "Beware the IP portfolio, everyone will be suspect of trespassing"
    David Bear Guest

  2. Similar Questions and Discussions

    1. Saving Print Settings in a Document via Print Advanced Menu
      I just discovered in the Help file you can do the above but it doesn't say how. I want to save the document so it can be printed on anyone's printer...
    2. Creating PDFs from Freehand -- print to PDFvs. export vs. print/scan to PDF?
      I've had a lot of compatibility problems with created presentations so have started using Acrobat instead of trying to export my Macromedia Freehand...
    3. print to pdf doesn't work. queue in the print center stopped
      hi, have a huge problem with printing a pdf. when i'm in illustrator for example and choose to print a simple page to pdf, it moves the file into...
    4. Exiting Print document within the print action
      Hello, I have a message to display when the user goes to print the document IF a certain condition is met. This part works fine. The message is a...
    5. Illustrator 10 Print Space settings in Print Dialog
      Howdy all; I've got a peculiar situation that I haven't found an answer to yet. On my laptop PC (Windows XP Home) when I go to print a document...
  3. #2

    Default Re: awk print

    On Wed, Feb 23, 2005 at 11:19:26PM +0100, Roland Smith wrote:
    > On Wed, Feb 23, 2005 at 02:40:10PM -0700, David Bear wrote:
    > > I'm using awk to parse a directory listing. I was hoping there is a
    > > way to tell awk to print from $2 - to the end of the columns
    > > available.
    > >
    > > find ./ -name '*stuff' | awk '{FS="/" print $3---'}
    >
    > Is this what you mean?:
    >
    > find ./ -name '*stuff'|sed 's|\.[^/]*/[^/]*/||g'
    thanks for the advice. No, this doesn't do what I want.

    If I have a directory path /stuff/stuff/more/stuff/more/and/more
    that is n-levels deep, I want to be able to cut off the first two
    levels and print the from 2 to the Nth level.
    >
    > Roland
    > --
    > R.F. Smith /"\ ASCII Ribbon Campaign
    > r s m i t h @ x s 4 a l l . n l \ / No HTML/RTF in e-mail
    > [url]http://www.xs4all.nl/~rsmith/[/url] X No Word docs in e-mail
    > public key: [url]http://www.keyserver.net[/url] / \ Respect for open standards


    --
    David Bear
    phone: 480-965-8257
    fax: 480-965-9189
    College of Public Programs/ASU
    Wilson Hall 232
    Tempe, AZ 85287-0803
    "Beware the IP portfolio, everyone will be suspect of trespassing"
    David Bear Guest

  4. #3

    Default Re: awk print

    * On Wed, Feb 23, 2005 at 07:36:05PM -0700 David Bear wrote:
    > On Wed, Feb 23, 2005 at 11:19:26PM +0100, Roland Smith wrote:
    > > On Wed, Feb 23, 2005 at 02:40:10PM -0700, David Bear wrote:
    > > > I'm using awk to parse a directory listing. I was hoping there is a
    > > > way to tell awk to print from $2 - to the end of the columns
    > > > available.
    > > >
    > > > find ./ -name '*stuff' | awk '{FS="/" print $3---'}
    > >
    > > Is this what you mean?:
    > >
    > > find ./ -name '*stuff'|sed 's|\.[^/]*/[^/]*/||g'
    >
    > thanks for the advice. No, this doesn't do what I want.
    >
    > If I have a directory path /stuff/stuff/more/stuff/more/and/more
    > that is n-levels deep, I want to be able to cut off the first two
    > levels and print the from 2 to the Nth level.
    So how about cut?

    find ./ -name '*stuff'| cut -d/ -f4-

    Mark

    --
    "The fix is only temporary...unless it works." - Red Green
    Mark Frank Guest

  5. #4

    Default Re: awk print

    You can set $[1..n] to "" and then print
    find ./ -name "stuff" | awk '{ $1=""; $2=""; print}


    On Wed, 23 Feb 2005 22:41:32 -0500, Mark Frank <mark@mark-and-erika.com> wrote:
    > * On Wed, Feb 23, 2005 at 07:36:05PM -0700 David Bear wrote:
    > > On Wed, Feb 23, 2005 at 11:19:26PM +0100, Roland Smith wrote:
    > > > On Wed, Feb 23, 2005 at 02:40:10PM -0700, David Bear wrote:
    > > > > I'm using awk to parse a directory listing. I was hoping there is a
    > > > > way to tell awk to print from $2 - to the end of the columns
    > > > > available.
    > > > >
    > > > > find ./ -name '*stuff' | awk '{FS="/" print $3---'}
    > > >
    > > > Is this what you mean?:
    > > >
    > > > find ./ -name '*stuff'|sed 's|\.[^/]*/[^/]*/||g'
    > >
    > > thanks for the advice. No, this doesn't do what I want.
    > >
    > > If I have a directory path /stuff/stuff/more/stuff/more/and/more
    > > that is n-levels deep, I want to be able to cut off the first two
    > > levels and print the from 2 to the Nth level.
    >
    > So how about cut?
    >
    > find ./ -name '*stuff'| cut -d/ -f4-
    >
    > Mark
    >
    > --
    > "The fix is only temporary...unless it works." - Red Green
    > _______________________________________________
    > [email]freebsd-questions@freebsd.org[/email] mailing list
    > [url]http://lists.freebsd.org/mailman/listinfo/freebsd-questions[/url]
    > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
    >
    Soheil Hassas Yeganeh Guest

  6. #5

    Default Re: awk print


    On 24 feb 2005, at 12:39, Soheil Hassas Yeganeh wrote:
    > You can set $[1..n] to "" and then print
    > find ./ -name "stuff" | awk '{ $1=""; $2=""; print}
    >
    >
    > On Wed, 23 Feb 2005 22:41:32 -0500, Mark Frank
    > <mark@mark-and-erika.com> wrote:
    >> * On Wed, Feb 23, 2005 at 07:36:05PM -0700 David Bear wrote:
    >>> On Wed, Feb 23, 2005 at 11:19:26PM +0100, Roland Smith wrote:
    >>>> On Wed, Feb 23, 2005 at 02:40:10PM -0700, David Bear wrote:
    >>>>> I'm using awk to parse a directory listing. I was hoping there is a
    >>>>> way to tell awk to print from $2 - to the end of the columns
    >>>>> available.
    >>>>>
    >>>>> find ./ -name '*stuff' | awk '{FS="/" print $3---'}
    >>>>
    >>>> Is this what you mean?:
    >>>>
    >>>> find ./ -name '*stuff'|sed 's|\.[^/]*/[^/]*/||g'
    >>>
    >>> thanks for the advice. No, this doesn't do what I want.
    >>>
    >>> If I have a directory path /stuff/stuff/more/stuff/more/and/more
    >>> that is n-levels deep, I want to be able to cut off the first two
    >>> levels and print the from 2 to the Nth level.
    >>
    >> So how about cut?
    >>
    >> find ./ -name '*stuff'| cut -d/ -f4-
    >>
    >> Mark
    or if you insist on using awk:

    find ./ -name '*stuff' | awk '{for (i=3; i<=NF; i++) printf " %s", $i;
    printf "\n" }'

    Arno

    FreeBSD questions mailing list Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139