WALK(1)WALK(1)

NAME

walk – walk a path

SYNOPSIS

walk [ -dftxu ] [ -n mind,maxd ] [ -e ststr ] [ name ... ]

DESCRIPTION

Walk recursively descends any directory arguments, printing the name of each file on a separate line. When no arguments are given, the current directory is assumed. Non-directory arguments are checked for existence, then printed, if so.

Options are:

-d

Print only directories.  

-f

Print only non-directories.  

-t

Print a file only if it has the temporary flag set.  

-x

Print a file only if it has any executable bits set.  

-u

Unbuffered output.  

-n min,max

Set the inclusive range of depths for filtering in results. Both min and max are optional.  

-e statfmt

Setting the statfmt string allows specifying the data walk should print. It takes a string of characters, each corresponding to some piece of information about the file being traversed, and prints them separated by spaces.  

The statfmt characters are as follows:

U

owner name (uid)  

G

group name (gid)  

M

name of last user to modify (muid)  

a

last access time (atime)  

m

last modification time (mtime)  

n

final path element (name)  

p

path  

q

qid path.version.type (see stat(2))  

s

size in bytes  

x

permissions  

The default statfmt is simply, p.

EXAMPLES

List files in a directory, sorted by modification time.

 

walk -femp catpics | sort -n | sed 's/^[^ ]+ //'

Print the size and path of files (excluding dirs) in the working directory.

 

walk -fn1 -esp

SOURCE

/sys/src/cmd/walk.c

SEE

ls(1), du(1)

BUGS

Statfmt character ‘x’ displays permissions as an integer.

Manipulating ifs is a nuisance.

File names are assumed to not contain newlines.

Correct invocation requires too much thought.