Pressing Enter (bash)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pressing Enter (bash)
# 8  
Old 02-07-2009
Quote:
Originally Posted by Yakuzan
How can I write a command right after an echo. It`s not working:

echo "Date : " `date + %d`

Am I writing it wrong?

Use printf:

Code:
printf "Date : "
date +%d

# 9  
Old 02-07-2009
Quote:
Originally Posted by cfajohnson
Use printf:

Code:
printf "Date : "
date +%d

I've never heard of printf, thanks a lot. Il read the man associated with it.

Edit: I just found out that you can also write echo "Date : " $(date +%d-%m)

Last edited by Yakuzan; 02-07-2009 at 02:58 PM..
# 10  
Old 02-07-2009
also this works as well:

Code:
echo "Date : `date +%d`"

Note the backtick command "inside" the double quotes for the echo command and NO space between the "+" and the format string (+%d).
# 11  
Old 02-08-2009
Hey, is their a command that directly displays the current directory?

I'm not talking about pwd.

I want the underlined part of let's say this pwd:

$HOME/bin/workfile1

See, I don't want the whole path, just the last part.

I though I could maybe pipe pwd with a few options but it's not going too great on my side.
# 12  
Old 02-08-2009
Code:
echo "${PWD##*/}"

# 13  
Old 02-09-2009
also:

Code:
basename `pwd`

or

Code:
basename ${PWD}

Many ways to skin a cat in *nix
# 14  
Old 02-09-2009
Quote:
Originally Posted by ddreggors
also:

Code:
basename `pwd`


Two exernal commands where none is needed.
Quote:

or

Code:
basename ${PWD}


An exernal command where none is needed.
Quote:

Many ways to skin a cat in *nix

But some are far more efficient than others.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script termination without pressing Enter key[nohup]

I have a script in which we have used nohup. Once script is executed it will be terminated only when enter key is pressed. I want the script to be terminated without pressing enter key nohup imqbrokerd -name user_id port 2>1 1>$home_`date` & I am a newbie to shell, Kindly please help (3 Replies)
Discussion started by: Suganbabu
3 Replies

2. Shell Programming and Scripting

Input password to bash script, save, and enter when needed

I am looking for a way to start a script and have it prompt for a password that will be used later on in the script to SSH to another host and to SFTP. I don't want the password to be hard coded. Below is my script with the actual IP's and usernames removed. #!/usr/bin/expect -f... (2 Replies)
Discussion started by: jbrass
2 Replies

3. Shell Programming and Scripting

How to pass enter key or selected character in bash script?

hi, i've bash script thats working... but now i need to add a line....that prompts for user input....like yes and 1 as complete install.... so here's how it looks... $ cd 9200 (cd into directory) $./install (hv to type ./install to run install then ask for) ----do you want to... (4 Replies)
Discussion started by: kernel11
4 Replies

4. Shell Programming and Scripting

Perl - start search by using search button or by pressing the enter key

#Build label and text box $main->Label( -text => "Input string below:" )->pack(); $main->Entry( -textvariable => \$text456 )->pack(); $main->Button( -text => "Search", -command => sub { errchk ($text456) ... (4 Replies)
Discussion started by: popeye
4 Replies

5. Shell Programming and Scripting

Want to write a command that keeps pressing enter key in regular interval

Hi, I m new to linux, can you pls help me to write a command/ script that keeps pressing the enter key in regular interval. Thx, Linux1 (2 Replies)
Discussion started by: mylinux1
2 Replies

6. Shell Programming and Scripting

Pressing enter and script still goes on

i have a bash shell script and i press enter and the script still continues on? how do i stop this (3 Replies)
Discussion started by: gangsta
3 Replies

7. Shell Programming and Scripting

How to enter a return key in bash script?

Hi, I'm porting an install script from AIX to Red Hat (2.6.18-164.el5 #1 SMP) I have this script working in both AIX and HP-UX. The script is a wrapper for a Micro Focus Server Express install program. It responds to the install program questions with a here-now list. Responses includes... (14 Replies)
Discussion started by: duker61
14 Replies

8. Shell Programming and Scripting

Pressing "Enter/Space bar" using Net::TELNET? in Perl

I'm trying to learn how to get my script to execute the enter button when it telnets into a router and the router displays output but you need to press the space bar or enter button to continue displaying my output of the router. How is this done? (0 Replies)
Discussion started by: xmaverick
0 Replies

9. Shell Programming and Scripting

BASH: Any Way to Get User Input Without Requiring Them to Hit the Enter Key?

I'm working on making a menu system on an HP-UX box with Bash on it. The old menu system presents the users with a standard text menu with numbers to make selections. I'm re-working the system and I would like to provide something more akin to iterative search in Emacs. I have a list of 28... (2 Replies)
Discussion started by: deckard
2 Replies

10. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies
Login or Register to Ask a Question