Чтение онлайн

на главную - закладки

Жанры

Искусство программирования на языке сценариев командной оболочки

Купер Мендель

Шрифт:

../Built-Shared -> Built-Static

../linux-2.4.20.tar.bz2 -> ../../../SRCS/linux-2.4.20.tar.bz2

The first character of the 11 (10?) character permissions field:

's' Socket

'd' Directory

'b' Block device

'c' Character device

'l' Symbolic link

NOTE: Hard links not marked - test for identical inode numbers

on identical filesystems.

All information about hard linked files are shared, except

for the names and the name's location in the directory system.

NOTE: A "Hard link" is known as a "File Alias" on some systems.

'-' An undistingushed file

Followed by three groups of letters for: User, Group, Others

Character 1: '-' Not readable; 'r' Readable

Character 2: '-' Not writable; 'w' Writable

Character 3, User and Group: Combined execute and special

'-' Not Executable, Not Special

'x' Executable, Not Special

's' Executable, Special

'S' Not Executable, Special

Character 3, Others: Combined execute and sticky (tacky?)

'-' Not Executable, Not Tacky

'x' Executable, Not Tacky

't' Executable, Tacky

'T' Not Executable, Tacky

Followed by an access indicator

Haven't tested this one, it may be the eleventh character

or it may generate another field

' ' No alternate access

'+' Alternate access

LSfieldsDoc

ListDirectory

{

local -a T

local -i of=0 # Default return in variable

# OLD_IFS=$IFS # Using BASH default ' \t\n'

case "$#" in

3) case "$1" in

– of) of=1 ; shift ;;

* ) return 1 ;;

esac ;;

2) : ;; # Poor man's "continue"

*) return 1 ;;

esac

# NOTE: the (ls) command is NOT quoted (")

T=( $(ls --inode --ignore-backups --almost-all --directory \

– -full-time --color=none --time=status --sort=none \

– -format=long $1) )

case $of in

# Assign T back to the array whose name was passed as $2

0) eval $2=\( \"\$\{T\[@\]\}\" \) ;;

# Write T into filename passed as $2

1) echo "${T[@]}" > "$2" ;;

esac

return 0

}

# # # # # Is that string a legal number? # # # # #

#

# IsNumber "Var"

# # # # # There has to be a better way, sigh...

IsNumber

{

local -i int

if [ $# -eq 0 ]

then

return 1

else

(let int=$1) 2>/dev/null

return $? # Exit status of the let thread

fi

}

# # # # # Index Filesystem Directory Information # # # # #

#

# IndexList "Field-Array-Name" "Index-Array-Name"

# or

# IndexList -if Field-Array-Filename Index-Array-Name

# IndexList -of Field-Array-Name Index-Array-Filename

# IndexList -if -of Field-Array-Filename Index-Array-Filename

# # # # #

: << IndexListDoc

Walk an array of directory fields produced by ListDirectory

Having suppressed the line breaks in an otherwise line oriented

report, build an index to the array element which starts each line.

Each line gets two index entries, the first element of each line

(inode) and the element that holds the pathname of the file.

The first index entry pair (Line-Number==0) are informational:

Index-Array-Name[0] : Number of "Lines" indexed

Index-Array-Name[1] : "Current Line" pointer into Index-Array-Name

The following index pairs (if any) hold element indexes into

the Field-Array-Name per:

Index-Array-Name[Line-Number * 2] : The "inode" field element.

NOTE: This distance may be either +11 or +12 elements.

Index-Array-Name[(Line-Number * 2) + 1] : The "pathname" element.

NOTE: This distance may be a variable number of elements.

Next line index pair for Line-Number+1.

IndexListDoc

IndexList

{

local -a LIST # Local of listname passed

local -a -i INDEX=( 0 0 ) # Local of index to return

local -i Lidx Lcnt

local -i if=0 of=0 # Default to variable names

case "$#" in # Simplistic option testing

0) return 1 ;;

1) return 1 ;;

2) : ;; # Poor man's continue

3) case "$1" in

– if) if=1 ;;

– of) of=1 ;;

* ) return 1 ;;

esac ; shift ;;

4) if=1 ; of=1 ; shift ; shift ;;

*) return 1

esac

# Make local copy of list

case "$if" in

0) eval LIST=\( \"\$\{$1\[@\]\}\" \) ;;

1) LIST=( $(cat $1) ) ;;

esac

# Grok (grope?) the array

Lcnt=${#LIST[@]}

Lidx=0

until (( Lidx >= Lcnt ))

do

if IsNumber ${LIST[$Lidx]}

then

local -i inode name

local ft

inode=Lidx

local m=${LIST[$Lidx+2]} # Hard Links field

ft=${LIST[$Lidx+1]:0:1} # Fast-Stat

case $ft in

b) ((Lidx+=12)) ;; # Block device

Поделиться:
Популярные книги

Драконий подарок

Суббота Светлана
1. Королевская академия Драко
Любовные романы:
любовно-фантастические романы
7.30
рейтинг книги
Драконий подарок

На границе империй. Том 10. Часть 3

INDIGO
Вселенная EVE Online
Фантастика:
боевая фантастика
космическая фантастика
попаданцы
5.00
рейтинг книги
На границе империй. Том 10. Часть 3

Сердце для стража

Каменистый Артем
5. Девятый
Фантастика:
фэнтези
боевая фантастика
9.20
рейтинг книги
Сердце для стража

Жандарм 3

Семин Никита
3. Жандарм
Фантастика:
попаданцы
альтернативная история
аниме
5.00
рейтинг книги
Жандарм 3

Жена на пробу, или Хозяйка проклятого замка

Васина Илана
Фантастика:
попаданцы
фэнтези
5.00
рейтинг книги
Жена на пробу, или Хозяйка проклятого замка

Эволюционер из трущоб. Том 5

Панарин Антон
5. Эволюционер из трущоб
Фантастика:
попаданцы
аниме
фэнтези
фантастика: прочее
5.00
рейтинг книги
Эволюционер из трущоб. Том 5

Отмороженный 11.0

Гарцевич Евгений Александрович
11. Отмороженный
Фантастика:
боевая фантастика
рпг
попаданцы
фантастика: прочее
фэнтези
5.00
рейтинг книги
Отмороженный 11.0

Неучтенный. Дилогия

Муравьёв Константин Николаевич
Неучтенный
Фантастика:
боевая фантастика
попаданцы
7.98
рейтинг книги
Неучтенный. Дилогия

Бастард Императора. Том 7

Орлов Андрей Юрьевич
7. Бастард Императора
Фантастика:
городское фэнтези
попаданцы
аниме
фэнтези
5.00
рейтинг книги
Бастард Императора. Том 7

Бастард Императора. Том 4

Орлов Андрей Юрьевич
4. Бастард Императора
Фантастика:
попаданцы
аниме
фэнтези
фантастика: прочее
5.00
рейтинг книги
Бастард Императора. Том 4

Кодекс Крови. Книга VII

Борзых М.
7. РОС: Кодекс Крови
Фантастика:
боевая фантастика
попаданцы
аниме
5.00
рейтинг книги
Кодекс Крови. Книга VII

Идеальный мир для Лекаря 5

Сапфир Олег
5. Лекарь
Фантастика:
фэнтези
юмористическая фантастика
аниме
5.00
рейтинг книги
Идеальный мир для Лекаря 5

Камень. Книга 3

Минин Станислав
3. Камень
Фантастика:
фэнтези
боевая фантастика
8.58
рейтинг книги
Камень. Книга 3

Матабар

Клеванский Кирилл Сергеевич
1. Матабар
Фантастика:
фэнтези
5.00
рейтинг книги
Матабар