drwxr-xr-x 24 h staff 816 Jun 8 10:55 csdrwxr-xr-x 6 h staff 204 Jun 8 10:55 draftdrwxr-xr-x 9 h staff 306 Jun 8 10:55 filesdrwxr-xr-x 2 h staff 68 Jun 9 13:19 hacksdrwxr-xr-x 6 h staff 204 Jun 8 10:55 mastersdrwxr-xr-x 4 h staff 136 Jun 8 10:55 static
4. Bash脚本(不推荐用于包含空格的文件名)
示例:for i in $(ls -d */); do echo ${i%%/}; done 这是我得到的:
csdraftfileshacksmastersstatic
如果您喜欢以“/”作为结束字符,命令将是:for i in $(ls -d */); do echo ${i}; done
cd "/path/to/pricipal/folder"
for i in $(ls -d .*/); do sudo ln -s "$PWD"/${i%%/} /home/inukaze/${i%%/}; done
ln: «/home/inukaze/./.»: can't overwrite a directoryln: «/home/inukaze/../..»: can't overwrite a directoryln: accesing to «/home/inukaze/.config»: too much symbolics links levelsln: accesing to «/home/inukaze/.disruptive»: too much symbolics links levelsln: accesing to «/home/inukaze/innovations»: too much symbolics links levelsln: accesing to «/home/inukaze/sarl»: too much symbolics links levelsln: accesing to «/home/inukaze/.e_old»: too much symbolics links levelsln: accesing to «/home/inukaze/.gnome2_private»: too much symbolics links levelsln: accesing to «/home/inukaze/.gvfs»: too much symbolics links levelsln: accesing to «/home/inukaze/.kde»: too much symbolics links levelsln: accesing to «/home/inukaze/.local»: too much symbolics links levelsln: accesing to «/home/inukaze/.xVideoServiceThief»: too much symbolics links levels
# Long list only directoriesllod () {ls -l --color=always "$@" | grep --color=never '^d'}
把它放在你的. bashrc文件中。
使用示例:
llod # Long listing of all directories in current directoryllod -tr # Same but in chronological order oldest firstllod -d a* # Limit to directories beginning with letter 'a'llod -d .* # Limit to hidden directories
注意:如果您使用-i选项,它会中断。这是一个修复:
# Long list only directoriesllod () {ls -l --color=always "$@" | egrep --color=never '^d|^[[:digit:]]+ d'}
-d List directories only.-f Prints the full path prefix for each file.-i Makes tree not print the indentation lines, useful when used in conjunction with the -f option.
如果你想要绝对路径,你可以从指定当前目录的完整路径开始:
$ tree -dfi "$(pwd)"/home/alice/Documents/home/alice/Documents/data/home/alice/Documents/data/sql/home/alice/Documents/images
为了限制子目录的数量,您可以使用-L level设置子目录的最大级别,例如:
$ tree -dfi -L 1 "$(pwd)"/home/alice/Documents/home/alice/Documents/data/home/alice/Documents/images
echo */echo ./*/ ### Avoid misinterpreting filenames like "-e dir"
将(通过shell)扩展到PWD中的所有目录echo。
要测试这一点:创建一个名为test-dir的目录(mkdir),并将cd放入其中:
mkdir test-dir; cd test-dir
创建一些目录:
mkdir {cs,files,masters,draft,static} # Safe directories.mkdir {*,-,--,-v\ var,-h,-n,dir\ with\ spaces} # Some a bit less secure.touch -- 'file with spaces' '-a' '-l' 'filename' # And some files:
file * | grep directory | cut -d':' -f1mongo-example-masternostarchscriptzzsplunktestdir
* could be replaced with any path that's permittedfile - determine file typegrep - searches for string named directory-d - to specify a field delimiter-f1 - denotes field 1