05-27-2008
Ubuntu shell script
I got the below script on line but can't seem to get it to work as there are syntax errors where 'len' is shown. Can anyone help with this??
echo " Enter the String"
read str
echo $str > str.txt
len = 'echo $str | wc -c'
len = 'expr $len -1'
c= 0 , w = 0 , s = 0 , i = 1
echo " Length of string = $len"
w = 'echo $str | wc - w'
c = 'echo $str | wc -c'
while [ i -le $ len ]
do
st = 'cut - c$I str.txt'
if ["str" = " "] then
s = 'expr $s + 1'
fi
i = 'expr $i + 1
done
echo "Character = $c"
echo "Words = $w"
echo "Spaces = $s"
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have tried few examples in the internet but all of them are different and none worked. I need to check if a file exists in a directory if it does not then exit . here is what I have for now
$filename ="/usr/local/net/var/lib/directoryservice/sync.disable"
if ;
then
echo "The file exists"... (2 Replies)
Discussion started by: m_kk
2 Replies
2. Shell Programming and Scripting
Hi all,
I am facing a situation here..
My default shell is BASH.
I have to change my shell from bash to ksh in ubuntu..
I have used chsh -s /bin/ksh. It doesn't work.
Is there any way to set or configure it..?
Please advice...:confused: (4 Replies)
Discussion started by: jdash.ps
4 Replies
3. Programming
Hi all,
I have an assignment from school to write a shell program in linux. the idea is to exercise fork() and execv() functions.. the shell program is supposed to be the master and every command that the user prints will run in a new process. we also need to try running the command in every... (1 Reply)
Discussion started by: r3vive
1 Replies
4. Ubuntu
Ubuntu 12.04 using gnome-shell
I just removed the entire unity unity-2d gnome desktop and installed the barebones essentials "gnome-shell" and all is working fine. The problem that I have noticed seems to be with permissions. These are the things that I cannot do:
1 -(tty access)
... (1 Reply)
Discussion started by: metallica1973
1 Replies
5. Ubuntu
I think it may be a bug:
This is the scenario:
I installed a barebones Ubuntu 12.04 using GNOME-SHELL on a usbstick(work related project). All worked fine from the laptop that I did the installation from. It grabbed an ip address automatically assigning the nic (eth0) and the wireless... (1 Reply)
Discussion started by: metallica1973
1 Replies
6. UNIX for Dummies Questions & Answers
Terminator is a program that allows users to set up flexible arrangements of GNOME terminals.
It has stopped working for me after upgrading to ubuntu 11.10. it does not give prompt to type anything. Just stuck with /bin/bash in the title.
I removed and installed again, same... (2 Replies)
Discussion started by: analyst
2 Replies
7. Ubuntu
pleas suggest free e books to begin Bash scripting in ubuntu..... (2 Replies)
Discussion started by: vyom
2 Replies
8. Shell Programming and Scripting
https://www.unix.com/attachment.php?attachmentid=6304&d=1432179166
how can draw line like this? on ubuntu, shell programming.
i tried "-" , " l " but it's failed.. (2 Replies)
Discussion started by: gotit
2 Replies
9. Shell Programming and Scripting
Are basic scripts in awk or bash or perl or other shell scripting languages the same in RHEL red hat as ubuntu? (1 Reply)
Discussion started by: cmccabe
1 Replies
10. UNIX for Beginners Questions & Answers
Hi,so today is my first day with linux.
I have some scripts from a friend and now im trying to run them but it doesnt work. So what i tried is:
-Moved the scripts to a specific directoy (into my document folder)
-then i opened the standard terminal in ubuntu (GNOME-Terminal)
-i typed in "Ls",... (3 Replies)
Discussion started by: easy123
3 Replies
escape(1) Mail Avenger 0.8.3 escape(1)
NAME
escape - escape shell special characters in a string
SYNOPSIS
escape string
DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result.
EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string:
$ var='; echo gotcha!'
$ eval echo hi $var
hi
gotcha!
$
Using escape, one can avoid executing the contents of $var:
$ eval echo hi `escape "$var"`
hi ; echo gotcha!
$
A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For
example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient:
#!/bin/sh
formail -x to -x cc -x resent-to -x resent-cc
| fgrep "$1" > /dev/null
&& exit 0
echo "<$1>.. address does not accept blind carbon copies"
exit 100
To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt
script:
bodytest reject_bcc `escape "$RECIPIENT"`
SEE ALSO
avenger(1),
The Mail Avenger home page: <http://www.mailavenger.org/>.
BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells.
AUTHOR
David Mazieres
Mail Avenger 0.8.3 2012-04-05 escape(1)