WALK(1)WALK(1)

NAME

walk – walk a path

SYNOPSIS

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

DESCRIPTION

Walk recursively descends any directory arguments, printing the name of each file on a separate line. When no arguments are given, the working 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. An argument of n with no comma is equivalent to 0,n.  

-e statfmt

Specify the output format. Each character in statfmt specifies a file attribute to display. The printed attributes are 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  

D

server device  

T

server type (kernel device rune)  

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.

HISTORY

Walk first appeared in 9front (March, 2019).