I would like to redirect the command executed along with the output to a file.
for example: #ls >ls_out.txt
ls_out.txt should be something like :
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
You could use "script" command: Something like this:
localhost:test_sf user1$ ls file1 file2 file3 localhost:test_sf user1$ script ls_out.txt #starting script command ls_out.txt will contain output Script started, output file is ls_out.txt bash-3.2$ ls file1 file2 file3 ls_out.txt bash-3.2$ exit exit Script done, output file is ls_out.txt =================================================================================== localhost:test_sf user1$ cat ls_out.txt #verify the contents now. Script started on Wed Dec 18 12:05:23 2013 bash-3.2$ ls file1 file2 file3 ls_out.txt bash-3.2$ exit exit
You will just have to get rid off "bash-3.2$ exit exit" piece.