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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-02-2008, 08:51 AM
|
#1
|
Member
Registered: Oct 2007
Posts: 53
Rep:
|
shell scripting/redefining your PATH
hellow,
im really confused,
how can i create a .profile file that would give me the number of the command, and the HISTSIZE variable initialized at 20 everytime i use the prompt ?
thank you for ur help
maya
|
|
|
01-02-2008, 09:26 AM
|
#2
|
Member
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446
Rep:
|
I'm not sure I understand what you want.
In my ~/.profile I have this:
export HISTFILESIZE=10
export HISTSIZE=100
the histfilesize chops down the history file to 10 lines upon login. (Atleast for a login shell)
while the histsize is the maximum size of the file after login. Change these values to suit your needs 
|
|
|
01-02-2008, 09:26 AM
|
#3
|
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853
Rep:
|
What do you mean by "the number of the command"; do you mean the process number or the command history number?
Also, when asking questions about shell-scripting, please provide some sort of inkling as to which shell you're using. Although the Bourne shell (sh) and the Bourne-again shell (bash) are the most popular, that does not necessarily mean that is the shell at hand - as different shells (quite often) have different syntaxes and environment variables.
EDIT: Also, please use pertinent thread titles; this post has nothing to do with redefining the $PATH environment variable.
Last edited by indienick; 01-02-2008 at 09:30 AM.
Reason: Wrist-slapping.
|
|
|
01-02-2008, 09:55 AM
|
#4
|
Member
Registered: Oct 2007
Posts: 53
Original Poster
Rep:
|
hellow,
thanks alot for the quick reply
i am using bash. sorry 4 not mentioning that!
i called my question redifining your path, because im supposed to add this to my path if i want it(the command-nr "fc -l" and the HISTSIZE variable) to work(be stated) everytime i log in i suppose ?
and thats what im trying to do !!!
BUT sadly without success !
maya
Last edited by mayaabboud; 01-02-2008 at 09:56 AM.
|
|
|
01-02-2008, 10:21 AM
|
#5
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
PATH is an environment variable that contains a list of directories in which to look for executables, meaning that you don't have to type the full path to the executable when you want to run a program (/usr/bin/foo vs. foo). fc is a Bash built in command (i.e. it doesn't have a separate exeuctable). Not sure which file you need to modify for your purposes, though.
|
|
|
01-02-2008, 10:56 AM
|
#6
|
Member
Registered: Oct 2007
Posts: 53
Original Poster
Rep:
|
i need to create a .profile file that gives me the result of the fc -l command and the variable HISTSIZE=20 when i log in ,
in order to do this, doesnt mean that i have to add it to my PATH ?
but i ve been trying to write that in a file all day
nthg seems 2 work
maya
|
|
|
01-02-2008, 11:02 AM
|
#7
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep: 
|
Quote:
Originally Posted by mayaabboud
in order to do this, doesnt mean that i have to add it to my PATH ?
|
No, because 1. that's not what PATH is for and 2. you couldn't do that anyway, since fc is a shell built-in command and doesn't have an executable anywhere in the file system.
|
|
|
01-02-2008, 11:36 AM
|
#8
|
Member
Registered: Oct 2007
Posts: 53
Original Poster
Rep:
|
this reply answers one question, but i still havent got a clue how to do this !!
|
|
|
01-02-2008, 11:45 AM
|
#9
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
What do you want to do? Do you want your command history displayed when you start a new shell? Why not create an alias for "fc -nl". For example: alias h='fc -nl'. Then you only need to type a single letter to see your history.
Last edited by jschiwal; 01-02-2008 at 11:49 AM.
|
|
|
01-02-2008, 12:47 PM
|
#10
|
Senior Member
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853
Rep:
|
Okay - two things off the top of my head. I think I know what you're trying to get at...
1. Word of warning: avoid making changes to /etc/profile. If you want EVERY user on the system to have this functionality, then by all means, edit this file. However, if you're the only user who requires this (or you are the only user on the system), write any changes to your ~/.bashrc file.
2. Query: Where, exactly, do you want to keep the output of "fc -l"? Where do you want it to show? Setting the $HISTSIZE variable isn't anything tricky, I'm just curious as to where you want to keep, and what you want to do with the "fc -l" value.
Code:
# ~/.bashrc Sample Exerpt
export FOO = $(fc -l)
export HISTSIZE = 20
Easy peasy! Of course, change "FOO" to a variable name that makes sense as to what you want to use the value for, but now you can do what you want with it. HOWEVER, I don't think you can force "fc -l" to run upon every command issued to the shell (unless you maybe figure something out with "alias").
|
|
|
01-02-2008, 12:50 PM
|
#11
|
Member
Registered: Oct 2007
Posts: 53
Original Poster
Rep:
|
answer to query: i would like the prompt to give me the value of FOO and the HISTSIZE variable when i log in on the prompt, and type sthg, i want it to give me these 2 pieces of info !
thx again alot for all of ur help
maya
|
|
|
All times are GMT -5. The time now is 06:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|