![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [kornshell] Getting the next weekday date | rs_f01 | UNIX for Dummies Questions & Answers | 1 | 08-10-2005 12:34 AM |
| Need Help with KornShell script | ckrieger1 | Shell Programming and Scripting | 1 | 02-13-2004 10:34 AM |
| Kornshell convdate | nezster | High Level Programming | 10 | 12-30-2003 12:17 PM |
| mailx in kornshell script passing return code to CA-Unicenter | Connie | UNIX for Advanced & Expert Users | 1 | 04-23-2002 09:45 AM |
| Kornshell 93 | Ask Me | UNIX for Dummies Questions & Answers | 1 | 07-12-2001 05:56 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
help with Kornshell function
I am trying to write a Kornshell function that takes a string parameter which represents a filename or directory name. The function checks to see if there are any spaces in the filename or directory name and then replaces the spaces with an underscore. The returned value is a filename or directory name without any spaces. Thanks for any suggestions you may have.
|
|
||||
|
Code:
#! /bin/ksh
result=""
differ=0
function repspace
{
differ=0
echo $1 | grep -q " "
if [ $? -eq 0 ] ; then
result=`echo $1 | sed 's/ /_/g'`
differ=1
fi
}
for file in *.shl
do
repspace $file
if [ differ -eq 1 ] ; then
mv $file $result
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|