Re: [PATCH v2]: Shell script for printing XFS quota project id for files.

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

 



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@xxxxxxxx>
> ---
.....
> @@ -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@xxxxxxxxxxxxx

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



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux