I am attempting to pass a string into awk and loop through it, and then for every occurrance of a certain character perform an action. In this case, for example, echo 1 for each time character r is found in the string. Except I can't get it to work. Could someone please tell me why?
echo... (7 Replies)
#!/usr/bin/ksh
echo Please enter
while read n
do
echo $n >> datafile
done
question:
How can I enject an if statement that if the users enter 0 (zero) the program will exit?
this is what I have but not working
#!/usr/bin/ksh
echo Please enter number
while read n
do
if $n=0
then... (2 Replies)
I'm having a question about for loops. (bash)
I have the following for example:
for file in `ls *.txt`
do
read file ...
done
Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Hello All,
This question is actually for the service console of VMware ESX 3.5 but is relevant to this forum I think. I have been advised to use the following commands:
for i in `find /vmfs/volumes/Test_VMFS/ -name "*.vmx"`
do
echo "$i"
#sed -i 's/scsi1:0.present =... (3 Replies)
Hey guys,
a=`cat abc | wc -l`
b=`cat def | wc -l`
if $a== $b
then
echo "a"
else
echo "b"
fi
I want the if condition to retry itself , untill a==b.
I can't use goto statemt.
Please help.
Thanx in advance.
Please use next time code tags for your code and data (5 Replies)
I need to check if an entry input by the user is in a file. If so, I need to run a command, and if it does not exist then it should output entry does not exist.
So I have so far...
echo "Enter record:"
read record
//command || //command
Can I use an if statement to do this? (3 Replies)
I need to match multiple values in a single column in a file:
example:
Source file:
abd,123,one
def,232,two
ghi,987,six
Target file:
12345,abcde,123
09876,zxvyr,566
56789,lmnop,232
Variable:
var1=`grep 2 sourcefile | awk '{print$1}'
essentially, echo "$var1" would read:... (2 Replies)
Hi,
I'm a rookie who is trying to learn this stuff. What I need help with is putting together a non complicated "while" loop within the below "if" statement. I also need the while loop to keep looping until the user types a key to end the loop. Please reveal the proper insertion points. Thank... (4 Replies)
Hello ALL,
need a BASH script who find file and send email with attachment.
I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as... (1 Reply)
Hi,
I am comparing the number of records in the .bad record from sql loader, if it is higher than the number passed in as an argument, the program should exit. However, I constantly receive the error " 0403-016 Cannot find or open the file." on the line with the if statement "elif ;". The code... (3 Replies)
Discussion started by: MIA651
3 Replies
LEARN ABOUT SUNOS
dirname
basename(1) User Commands basename(1)NAME
basename, dirname - deliver portions of path names
SYNOPSIS
/usr/bin/basename string [suffix]
/usr/xpg4/bin/basename string [suffix]
dirname string
DESCRIPTION
The basename utility deletes any prefix ending in / and the suffix (if present in string) from string, and prints the result on the stan-
dard output. It is normally used inside substitution marks (``) within shell procedures.
/usr/bin
The suffix is a pattern defined on the expr(1) manual page.
/usr/xpg4/bin
The suffix is a string with no special significance attached to any of the characters it contains.
The dirname utility delivers all but the last level of the path name in string.
EXAMPLES
Example 1: Setting environment variables
The following example, invoked with the argument /home/sms/personal/mail sets the environment variable NAME to the file named mail and the
environment variable MYMAILPATH to the string /home/sms/personal:
example% NAME=`basename $HOME/personal/mail`
example% MYMAILPATH=`dirname $HOME/personal/mail`
Example 2: Compiling a file and moving the output
This shell procedure, invoked with the argument /usr/src/bin/cat.c, compiles the named file and moves the output to cat in the current
directory:
example% cc $1
example% mv a.out `basename $1 .c`
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of basename and dirname: LANG, LC_ALL,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
/usr/bin
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
/usr/xpg4/bin
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWxcu4 |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO expr(1), basename(3C), attributes(5), environ(5), standards(5)SunOS 5.10 18 Mar 1997 basename(1)