LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-25-2010, 09:35 PM   #1
supulton
LQ Newbie
 
Registered: Feb 2010
Posts: 21

Rep: Reputation: 0
echo function in .bashrc


Hello, I'd like a function in my .bashrc file that would allow me to pass text to it and echo the text to a specified file.

I know it's simple as "echo 'text' >> file," but ideally, I would want to alias the function so I execute something like:
Code:
user~ $ write 'this is a test'
with "write" being the function, and 'this is a test' being echoed to the file. I hope I explained that well enough.
 
Old 02-25-2010, 10:15 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
What's wrong with writing the function as a script called "write", and putting the script in your path?
 
Old 02-25-2010, 10:19 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Start here http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html
 
Old 02-25-2010, 10:34 PM   #4
supulton
LQ Newbie
 
Registered: Feb 2010
Posts: 21

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by chrism01 View Post
Thanks. The parameter passing is what I was after.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"exit" in bash .bashrc procedure/shell function exits xterm anonguy9 Linux - Newbie 11 07-13-2011 04:54 PM
echo from a function JohnnyBoy123 Linux - Newbie 8 04-20-2009 08:28 PM
.bashrc function not executed in fc8 Callandor Linux - Software 1 02-23-2008 06:16 AM
function in .bashrc ovince Programming 6 04-25-2007 01:26 PM
alias or function in .bashrc, which sends command to background ngomong Linux - General 1 04-23-2002 10:50 PM


All times are GMT -5. The time now is 11:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration