LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-02-2008, 08:51 AM   #1
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Rep: Reputation: 15
Unhappy 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
 
Old 01-02-2008, 09:26 AM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
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
 
Old 01-02-2008, 09:26 AM   #3
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
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.
 
Old 01-02-2008, 09:55 AM   #4
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
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.
 
Old 01-02-2008, 10:21 AM   #5
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
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.
 
Old 01-02-2008, 10:56 AM   #6
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
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
 
Old 01-02-2008, 11:02 AM   #7
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by mayaabboud View Post
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.
 
Old 01-02-2008, 11:36 AM   #8
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
this reply answers one question, but i still havent got a clue how to do this !!
 
Old 01-02-2008, 11:45 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
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.
 
Old 01-02-2008, 12:47 PM   #10
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
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").
 
Old 01-02-2008, 12:50 PM   #11
mayaabboud
Member
 
Registered: Oct 2007
Posts: 53

Original Poster
Rep: Reputation: 15
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
 
  


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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
scripting path navigation toddcurry Programming 1 05-26-2005 10:09 PM
PATH Scripting louisb Linux - General 5 01-15-2004 08:42 AM

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

All times are GMT -5. The time now is 06:52 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
Open Source Consulting | Domain Registration