LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 11-12-2013, 11:00 PM   #1
rohit.dhaval1
Member
 
Registered: Jul 2009
Posts: 44
Blog Entries: 2

Rep: Reputation: 0
Unable to create a function in BASH


I want to create a function in .bashrc to ease checking version of perl module. Can someone help me create one

The command to be put in .bashrc is

perl -MXML::LibXML -e 'print "$XML::LibXML::VERSION\n"'

I want to be able to run above as


p XML::LibXML
 
Old 11-13-2013, 12:30 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
what have you done so far?
 
Old 11-26-2013, 07:14 AM   #3
rohit.dhaval1
Member
 
Registered: Jul 2009
Posts: 44

Original Poster
Blog Entries: 2

Rep: Reputation: 0
Sorry, didn't reply on time.. I figured out a way myself

>>>>> Lines from .bashrc

p () {
/usr/bin/perl -M"$@" -e 'print "$'"$@"'::VERSION\n"'
}
 
  


Reply

Tags
bash, function



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
[SOLVED] Is it possible to create a bash script to create multiple new bash scripts Batistuta_g_2000 Linux - Newbie 6 02-19-2013 11:42 AM
[SOLVED] Setting function default in a bash script - Bash sixtensixone Linux - General 13 01-08-2011 01:44 PM
Bash array Add function example using indirect array reference as function argument bobywelsh Programming 10 07-05-2010 04:44 AM
create a global associative array variable inside a function of a bash script konsolebox Programming 3 07-14-2009 06:08 AM
Bash looping or function within a function FirmbIT Programming 2 04-24-2006 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:51 PM.

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
Open Source Consulting | Domain Registration