LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 12-11-2006, 03:14 AM   #1
Volcano
Member
 
Registered: Sep 2005
Posts: 159

Rep: Reputation: 15
how to see which command has been executed ?


I am running couple of shell script like below..

$a.sh
$b.sh
$c.sh


Now i want to fire a command which could tell me what are the shell scripts has been executed .

so my expected output is :

a.sh
b.sh
c.sh


I am looking for some linux command which will give the history.

whats that ?
 
Old 12-11-2006, 04:01 AM   #2
tshrinivasan
Member
 
Registered: Jan 2006
Location: Chennai, Tamil nadu, India
Distribution: Debian Etch Testing
Posts: 117

Rep: Reputation: 16
history
is the command which gives us the history of commands executed in the system
 
Old 12-11-2006, 05:15 AM   #3
Broder
Member
 
Registered: Oct 2006
Location: Santa Barbara, C.A.
Distribution: Mood dependent
Posts: 117

Rep: Reputation: 15
The history command will list previous commands. You can also search within history if you know roughly what you're looking for. ie. If you want to find a list of all the cp commands you have executed then type history | grep cp. Previous commands are stored in bash_history, the number of commands that can be stored is controlled by the HISTSIZE variable. Type echo $HISTSIZE to see what this variable has been set to. You can change this from the commandline by typing HISTSIZE=500 for example.
 
Old 12-11-2006, 06:07 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
If you started your scripts in the background and they're still running, then the "jobs" command will list those.

Setting HISTSIZE to 0 will effectively disable the history.

Please also note that the history mechanism can vary depending on the shell you're using. So check your shell's man pages to be sure.
 
Old 12-11-2006, 09:48 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
from the bash manual page (yes, it's really really useful - you should read it!)
Code:
       history [n]
       history -c
       history -d offset
       history -anrw [filename]
       history -p arg [arg ...]
       history -s arg [arg ...]
              With no options, display the command history list with line num‐
              bers.  Lines listed with a * have been modified.  An argument of
              n lists only the last n lines.  If the shell variable  HISTTIMEFORMAT
              is  set  and not null, it is used as a format string for
              strftime(3) to display the time stamp associated with each  dis‐
              played  history  entry.  No intervening blank is printed between
              the formatted time stamp and the history line.  If  filename  is
              supplied,  it  is  used as the name of the history file; if not,
              the value of HISTFILE is used.  Options, if supplied,  have  the
              following meanings:
              -c     Clear the history list by deleting all the entries.
              -d offset
                     Delete the history entry at position offset.
              -a     Append  the  ‘‘new’’ history lines (history lines entered
                     since the beginning of the current bash session)  to  the
                     history file.
              -n     Read  the history lines not already read from the history
                     file into the current  history  list.   These  are  lines
                     appended  to  the history file since the beginning of the
                     current bash session.
              -r     Read the contents of the history file and use them as the
                     current history.
              -w     Write  the current history to the history file, overwrit‐
                     ing the history file’s contents.
              -p     Perform history substitution on the  following  args  and
                     display  the  result  on  the  standard output.  Does not
                     store the results in the history list.  Each arg must  be
                     quoted to disable normal history expansion.
              -s     Store  the  args  in  the history list as a single entry.
                     The last command in the history list  is  removed  before
                     the args are added.

              If the HISTTIMEFORMAT is set, the time stamp information associ‐
              ated with each history entry is written  to  the  history  file.
              The  return  value is 0 unless an invalid option is encountered,
              an error occurs while reading or writing the  history  file,  an
              invalid  offset is supplied as an argument to -d, or the history
              expansion supplied as an argument to -p fails.
 
  


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
which command executed on which terminal dsids Linux - Newbie 1 09-23-2006 09:57 AM
removing only most previously executed command from history? jagroop mand Linux - Newbie 2 01-19-2005 06:39 AM
No effect when 'export' command executed in a script? sylvain_gnu Linux - Software 6 04-20-2004 08:15 PM
How find which command has been executed by which user. HPUX 11.11 OS kshell murugesan Linux - Distributions 3 04-16-2004 06:26 AM
How do I undo last command executed? Elfking Linux - General 4 02-05-2004 02:18 AM


All times are GMT -5. The time now is 09:07 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration