Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Last character in a string
Name: Anukta C. Date: October 9, 2002 at 02:22:42 Pacific OS: HP-UX CPU/Ram: 256 MB
Comment:
Hi, I have to find out whether the last character of a string is a "/" or not. I have to accept a path from the stdin and find out whether it has a "/" in the end or not. If not, then append "/" to the end of the string. The logic runs thus:
echo "type the path of the file" read dat_path [find out the last character of the string] [If the last character of the string is not "/" then append a "/" to the end of the string]
This is what I want the program to do. I am having trouble with finding the last character of the string. Any ideas? -Anukta
Summary: How can I delete the last character in a file. I dont care what the character is - all i want to do is delete the last character. Whats the easiest way to do this? Any help is appreciated ...
Summary: hi, i would like to count the occurence of a character in a string using sed, any idea? e.g. count the no of ';' in 'abc;def;ghi;jkl' returns 3. Thanks in advance. ...
Summary: Hello, I try to detect the presence of a char in a string. This is korn shell. mystring="1234-" mychar="-" if [ mystring includes mychar ] ; then exist=1 else exist=0 fi What should I write inst...