shell scripting/ the fc -l command !
i wrote the following program:
# !/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 |
where did you read that "$fc $-l" would do what you want? that means nothing.... try "$((fc -l))" instead.
|
well after trying $(fc -l )
the only thing that wouldnt give me errors was $fc$-l !! i tried $((fc -l)), but that gives me 0, i want the same list that i get when i simply type fc -l on the xterm ! how can i do that? any idea ? |
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! :) |
neither 'fc -l' nor $(fc -l) worked !
i already tried those two, maybe i should add some argument or sthg? i cant get the answer that i want, $(fc -l) gives me hBl as an answer !! and 'fc -l' gives me fc -l as an answer !! |
actually $fc $-l gives me hBl as an answer
$(fc -l) gives me nth as an answer !! |
no it's `fc -l` not 'fc -l' but as above i don't think you should use that mechanism at all, just run it normally outside of echo.
|
what do you mean by outside of echo ?
i have this program:i changed the fc -l command : # !/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 BUT I GET NOTHG AS AN ANSWER ! |
# !/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 |
this also gives me "nthg" as an answer !
|
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 !! |
Quote:
Quote:
For example, consider this simple program (which I will save in a text file named program): Code:
#!/bin/sh Code:
$ chmod +x program Code:
$ source program |
All times are GMT -5. The time now is 11:47 PM. |