![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regular expressions | whatever | Shell Programming and Scripting | 4 | 05-20-2007 05:30 PM |
| Help with regular expressions | arushunter | Shell Programming and Scripting | 13 | 12-24-2006 12:31 AM |
| regular expressions | jack1981 | Shell Programming and Scripting | 4 | 07-12-2006 04:10 PM |
| regular expressions in c++ | szzz | High Level Programming | 2 | 10-06-2003 11:33 AM |
| Regular Expressions | AresMedia | Shell Programming and Scripting | 1 | 08-22-2002 04:55 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Regular Expressions
Hi,
below is a piece of code written by my predecessor at work. I'm kind of a newbie and am trying to figure out all the regular expressions in this piece of code. It is really a tough time for me to figure out all the regular expressions. Please shed some light on the regular expressions in this code ssh_list() { typeset userAtHost="$1" typeset dir="${2-.}" typeset wild="${3-*}" info "SSH list: $userAtHost $src $dst" if [ "$REGION" != prod ] ;then userAtHost=$LOGNAME@localhost fi # Save, disable, and restore the verbose flag - any # verbose output would look like errors. typeset verbose="$(set -o |sed -n 's/^verbose *//p')" set +v typeset msgs="$(sftp $userAtHost 2>&1 <<EOF cd $dir ls EOF)" if [ "$verbose" = on ] ;then set -v fi # Strip the "Connecting to host..." line, prompts, blank lines # and login banners. What's left should only be error messages. typeset errs="$(echo "$msgs" | sed -e '/^Connecting to .*\.\.\.$/d' \ -e 's/sftp > //g' \ -e '/^[ ]*$/d' \ -e '/^#/d' \ -e '/^[-dDlbcps][-rwxsStTlL]\{9\}+\{0,1\} /d')" if [ "$errs" != "" ] ;then error "$errs" return 1 fi echo "$msgs" | while read line do case "$line" in -*\ $wild) echo ${line##* } ;;esac done return 0 } I'd like some explanation of these lines.... gurus please shed some light. Thank you for your time. Ram |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|