SaCarde
utility bash
come elencare directory
- listano le directory presenti:
ls -d */
ls -l grep ^d
- lista directory ad albero
#!/bin/bash
#######################################################
# UNIX TREE #
# Version: 2.2 #
# By Dem Pilafian #
# File: ~/apps/tree/tree.sh #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
# in a single command to show the nesting of #
# sub-directories. #
# #
# Setup: #
# % cd ~/apps/tree #
# % chmod u+x tree.sh #
# % ln -s ~/apps/tree/tree.sh ~/bin/tree #
# #
# Usage: #
# % tree [directory] #
# #
# Examples: #
# % tree #
# % tree /etc/opt #
# % tree .. #
# #
# Public Domain Software -- Free to Use as You Like #
# http://www.centerkey.com/tree #
#######################################################
echo
if [ "$1" != "" ] #if parameter exists, use as base folder
then cd "$1"
fi
pwd
ls -R grep ":$" \
sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-//'
# 1st sed: remove colons
# 2nd sed: replace higher level folder names with dashes
# 3rd sed: indent graph three spaces
# 4th sed: replace first dash with a vertical bar
if [ `ls -F -1 grep "/" wc -l` = 0 ] # check if no folders
then echo " -> no sub-directories"
fi
echo
exit
- lista file senza commenti
grep -v ^# $1
Le ultime notizie relative a questo argomento
debian 9 su sun ultra 10 (22/08/2017 - 16:43) letto 1365 volte
compressione archivi in Linux (30/07/2016 - 17:48) letto 1484 volte
Il sistema di web learning della Regione Toscana (16/10/2014 - 20:56) letto 1617 volte
avventura stampante HP D1360 (cartuccia colore) (22/05/2010 - 13:36) letto 2241 volte
utility bash (06/07/2008 - 21:17) letto 1406 volte
Tutte le notizie relative a questo argomento