public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Arkadiusz Miśkiewicz" <arekm@maven.pl>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v2]: Shell script for printing XFS quota project id for files.
Date: Tue, 13 Nov 2012 09:14:24 +1100	[thread overview]
Message-ID: <20121112221424.GU24575@dastard> (raw)
In-Reply-To: <1352745628-15451-1-git-send-email-arekm@maven.pl>

On Mon, Nov 12, 2012 at 07:40:28PM +0100, Arkadiusz Miśkiewicz wrote:
> Simple script that prints project id for files:
> 
> $ sh quota/xfs_lsprojid.sh quota/[fl]*
> quota/freebsd.c: 232
> quota/free.c: 0
> quota/free.o: 222
> quota/linux.c: 21344
> quota/linux.o: 0
> 
> Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
> ---
.....
> @@ -0,0 +1,11 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2012 Arkadiusz Miśkiewicz.

Best to use only 7-bit ascii in code.

> +#
> +
> +for file in "$@"; do
> +        xfs_io -p "$0" -r -c "stat" "$file" | awk '
> +        /^fd\.path =/ { projid=""; gsub(/^fd\.path = \"/, ""); gsub(/\"$/, ""); path=$0 }
> +        /^fsxattr\.projid =/ { projid=$3; print path ": " projid; }
> +        '
> +done

Can you write it in a way that looks a little less like line
noise? This is much easier to understand:

	xfs_io -p "$0" -r -c "stat" "$file" | awk '
		/^fd\.path =/ {
			projid="";
			gsub(/^fd\.path = \"/, "");
			gsub(/\"$/, "");
			path=$0
		}
		/^fsxattr\.projid =/ {
			projid=$3;
			print path ": " projid;
		}'

It also needs a usage message when no files are given, and probably
a version output (-V option) as well.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2012-11-12 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12 18:33 [PATCH]: Shell script for printing XFS quota project id for files Arkadiusz Miśkiewicz
2012-11-12 18:40 ` [PATCH v2]: " Arkadiusz Miśkiewicz
2012-11-12 22:14   ` Dave Chinner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121112221424.GU24575@dastard \
    --to=david@fromorbit.com \
    --cc=arekm@maven.pl \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox