LinuxQuestions.org
Visit Jeremy's Blog.
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 04-25-2007, 07:55 PM   #1
psychonox
LQ Newbie
 
Registered: Apr 2007
Posts: 2

Rep: Reputation: 0
NEED HELP with a script!


Hi! i need help with a script in bash i want to print the last command i execute but with no vars and no echo for example i want to print a command that create directories:

mkdir ~/Desktop/Here<----this is executed
mkdir ~/Desktop/Here<---this is printed after top is executed with no echo or var

ivbeen trying with history but also with this unknown command at least for me: echo $_ like this

mkdir ~/Desktop/Here
echo $_ <---this print the last command but not mkdir ~/Desktop/Here so if u can help me!?


note: all this its inside a bash script
 
Old 04-25-2007, 08:50 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Not exactly sure what you want…

Is your desire to have “mkdir” printed after executing “mkdir ~/Desktop/Here” or do you want to have “mkdir ~/Desktop/Here” printed after executing “mkdir ~/Desktop/Here”? For the latter, have you tried a simple “set -x; mkdir ~/Desktop/Here; set +x”?
 
Old 04-26-2007, 01:16 AM   #3
psychonox
LQ Newbie
 
Registered: Apr 2007
Posts: 2

Original Poster
Rep: Reputation: 0
ooo the second thing u say! i wanna print the command after is executed let me try set -x thx
 
Old 04-26-2007, 03:44 AM   #4
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 960

Rep: Reputation: 35
why do you not want to use echo to print the command after its exicuted?

ie.
Code:
mkdir ~/Desktop/Here
echo " mkdir ~/Desktop/Here"
that is the normal way to print somthing in bash
 
Old 04-26-2007, 10:00 AM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Quote:
Originally Posted by dasy2k1
why do you not want to use echo to print the command after its exicuted?
I think he wants something a little more automated. The $_ variable stores the name of the last command’s last argument. AFAIK, there’s nothing like that for the last command itself, but the debugging mode in bash would do something similar.
 
Old 04-27-2007, 03:20 AM   #6
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 960

Rep: Reputation: 35
can you tail the end of your bash history file?
 
  


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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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