Programming

Post questions about C, C++, Java, SQL, and other programming languages here.

Keyboard User Input in awk language ?


👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-17-2017
Zabo Zabo is offline
Registered User
 
Join Date: Dec 2016
Last Activity: 15 June 2017, 4:56 PM EDT
Location: Germany
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Keyboard User Input in awk language ?

Hi,

does someone know how to make a keyboard data input

in the AWK programming language ?

Regards

Zabo
Sponsored Links
    #2  
Old 05-17-2017
RavinderSingh13 RavinderSingh13 is offline Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 19 July 2018, 12:48 PM EDT
Location: Chennai
Posts: 2,750
Thanks: 623
Thanked 1,316 Times in 1,183 Posts
Hello Zabo,

Here is an example for it.
Code:
awk 'BEGIN{print "Enter your Name: ";getline name < "-";print RS "Input entered by user is: "name}'

After running the above code following output will be coming.
Code:
Enter your Name:
R. Singh
Input entered by user is: R. Singh

Thanks,
R. Singh
The Following User Says Thank You to RavinderSingh13 For This Useful Post:
Zabo (05-17-2017)
Sponsored Links
    #3  
Old 05-17-2017
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 19 July 2018, 5:13 PM EDT
Location: Loughborough
Posts: 1,293
Thanks: 388
Thanked 352 Times in 277 Posts
https://www.unix.com/shell-programmin...input-awk.html
    #4  
Old 05-17-2017
Zabo Zabo is offline
Registered User
 
Join Date: Dec 2016
Last Activity: 15 June 2017, 4:56 PM EDT
Location: Germany
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Thank you , that works. R.Singh

The variable name has the value !


Regards Zabo

Last edited by Zabo; 05-17-2017 at 02:57 PM.. Reason: correction
Sponsored Links
    #5  
Old 05-17-2017
Corona688 Corona688 is online now Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 19 July 2018, 6:48 PM EDT
Location: Saskatchewan
Posts: 22,725
Thanks: 1,193
Thanked 4,350 Times in 4,005 Posts
...and if standard input is already something else, you can do getline < "/dev/stdin"
The Following User Says Thank You to Corona688 For This Useful Post:
Zabo (05-17-2017)
Sponsored Links
    #6  
Old 05-17-2017
Zabo Zabo is offline
Registered User
 
Join Date: Dec 2016
Last Activity: 15 June 2017, 4:56 PM EDT
Location: Germany
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Thank you.
Sponsored Links
    #7  
Old 05-17-2017
Corona688 Corona688 is online now Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 19 July 2018, 6:48 PM EDT
Location: Saskatchewan
Posts: 22,725
Thanks: 1,193
Thanked 4,350 Times in 4,005 Posts
Erm, I meant, < "/dev/tty" , to force it to read from keyboard even when stdin is a file.
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read input from Keyboard, do not proceed if no input aravindadla Shell Programming and Scripting 7 02-26-2016 01:24 PM
How to read user keyboard input inside the case? femchi Homework & Coursework Questions 2 11-08-2012 02:13 AM
Testing for correct user input from keyboard Pauline mugisha UNIX for Dummies Questions & Answers 0 11-29-2009 06:16 PM
Keyboard Input cpaquette Programming 4 04-07-2008 01:44 PM
suppressing keyboard input anthreedhr Shell Programming and Scripting 1 10-21-2004 11:05 AM



All times are GMT -4. The time now is 06:49 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?