Linux - NewbieThis 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.
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.
# !/bin/bash
#profile program
function histoire {
HISTSIZE=20
echo “HISTSIZE est égale à” $HISTSIZE
echo “le numéro de la commande est” $fc $-l
}
histoire
exit 0
can someone tell me, why am i not getting the same result, as in when i directly write the command fc -l ? and whats hBl ?
knoppix@knoppix:/ramdisk/home/knoppix/tmp$ chmod +x .profile
+ chmod +x .profile
knoppix@knoppix:/ramdisk/home/knoppix/tmp$ ./.profile
+ ./.profile
HISTSIZE est égale à 20
le numéro de la commande est hBl
yeah it does doesn't it? retard alert.... i knew it didn't look right... sorry, it does basic expression evalution...
# echo $(( 10 + 10 ))
20
you do need $(fc -l) or `fc -l` to actually execute fc as a command. i don't think that that's really useful to you though as it'll print it all on one line... i'd just put the fc command on a new line by itself.
doh!
Last edited by acid_kewpie; 01-03-2008 at 08:18 AM.
# !/bin/bash
#profile program
function histoire {
HISTSIZE=20
echo “HISTSIZE est égale à” $HISTSIZE
echo “le numéro de la commande est”
fc -l
}
histoire
exit 0
do you atually mean "nothing"...? or literally a text string as you wrote?? if fc -l doesn't give you an output, then you have no recorded history to output...
yes i actually mean nthg, just blank space ,
i have a recorded history to output, and i know that because when i type fc -l in my xterm then i get a long list !!
can someone tell me, why am i not getting the same result, as in when i directly write the command fc -l ? and whats hBl ?
Both of these questions have simple explanations. First, let’s see what fc does (taken from here):
Quote:
Originally Posted by The Open Group Base Specifications Issue 6
The fc utility shall list, or shall edit and re-execute, commands previously entered to an interactive sh.
As you can see, fc only works (or should only work) on an interactive shell (i.e., one in which you can interactively type commands).
For example, consider this simple program (which I will save in a text file named program):
Code:
#!/bin/sh
fc -l
Now, watch what happens when I try to execute it as a script:
Code:
$ chmod +x program
$ ./program
$
And watch what happens if I source it into my interactive shell:
Code:
$ source program
1 cd /tmp
2 cat > program
3 chmod +x program
4 ./program
$
As for “hBl”, this is the result expanding “$-l” in a script. You see, it shall be parsed as “${-}l” where the internal variable $- has the flags currently set (this is a ksh-ism borrowed by bash). In this case, the flags set are for brace expansion and command hashing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.