Article 502N4 Bash: .bash_profile function

Bash: .bash_profile function

by
DynV
from LinuxQuestions.org on (#502N4)
For what I'm attempting to do, please see the echo that start with description (which should be bold) in the .bash_profile content
Code:function omit_amp {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: omit_amp <any command that--might--contain an ampersand (\'&\')>"
echo "Example: omit_amp wget --limit-rate=300k --wait=2 --random-wait https://ubuntuforums.org/showthread.php?t=1234567&p=89012345#post89012345"
echo "Description: omit_amp will run anything it gets as argument up to an ampersand, which it will omit and all that follows."
return 1
else
${1%%\&*}
fi
}there was also an example (which should be italicized), which should end up running
Quote:
wget --limit-rate=300k --wait=2 --random-wait https://ubuntuforums.org/showthread.php?t=1234567
It's my understanding, which is quite fresh/new, that a function in .bash_profile content would be a good way to go about it.
Well, from it having for content the above code, here's the terminal content of my attempt to run it
Quote:
me@me-computer:~$ omit_amp wget --limit-rate=300k --wait=2 --random-wait https://ubuntuforums.org/showthread....5#post89012345
[1] 15111
me@me-computer:~$ omit_amp: command not found
which Quote:
me@me-computer
was censoring (for my privacy).

Please let me know what I'm doing wrong or a better way to end up with what's in the description and example.

Thank you kindly

Update 1: While I'd be happy with the former, my ultimate goal is for only the last string to be applied the S&R (search & replace). So is there was an ampersand in the command name or options, it wouldn't matter, only if the last string, in the example (in an echo in the code), only the URL would be submitted to S&R.latest?d=yIl2AUoC8zA latest?i=84r7VJwmpHE:B0ldYu-NCCk:F7zBnMy latest?i=84r7VJwmpHE:B0ldYu-NCCk:V_sGLiP latest?d=qj6IDK7rITs latest?i=84r7VJwmpHE:B0ldYu-NCCk:gIN9vFw84r7VJwmpHE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments