Bash: question about command line parsing
Hi, say last command was
Quote:
|
Quote:
Read the bash man page or a manual to find out which settings influence the retainment of history (hint: they start with HIST, in capitals). |
It depends what you want to do. You can seemingly, and easily "run" the last command using things like !! or !-1. If you want to contents of the last command, there's a trap capability in bash which you can use. Seems a lot of work, but I've seen it done.
https://www.ostechnix.com/5-ways-rep...command-linux/ https://stackoverflow.com/questions/...nd-run-in-bash |
Besides the history command there are some shortcuts, for example !! and !*
|
You can also use the up-arrow key to scroll back through the command history.
|
Quote:
Code:
$ ls -l |
The problem with each of !! and history, you get a list. Well, not a problem if you process it within your script.
Just noting that I think that igadoter wishes to do this operation within a script. And also that they haven't cited how they intend to use it exactly. It may be fine to use !! to re-run the prior command. Or if they wish to know what that former command was and store, modify, process it somehow, then I believe echo'ing !! will give you both the echo !! as well as the prior command. |
Quote:
Code:
$ while read LINE ; do echo $LINE ; done < my_bash_script |
Quote:
Code:
FOO=(!!) |
Quote:
Code:
$ while read -a LINE ; do echo ${#LINE[@]}: ${LINE[@]} ; done < my_bash_script Code:
55: find -L . ( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 ) -exec chmod 755 {} ; -o ( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 ) -exec chmod 644 {} ; |
hmm
it looks like you actually want something like this Code:
bash -x ./my_bash_script 2>debug.log you can also use within script Code:
set -x # turn it on I mostly just "go the whole hog" with bash -x but using set within the script to reduce the noise but I may be a little confused about what you are actually trying to achieve. |
Quote:
|
yeah, thought I was miss understanding something
Code:
sed -e :a -e '/\\$/N; s/\\\n//; ta' inputfile |
All times are GMT -5. The time now is 09:49 PM. |