Unix/Linux Go Back    


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

Keyboard User Input in awk language ?

Programming


Tags
awk, linux, unix

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-17-2017   -   Original Discussion by Zabo
Zabo's Unix or Linux Image
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 Unix and Linux 05-17-2017   -   Original Discussion by Zabo
RavinderSingh13's Unix or Linux Image
RavinderSingh13 RavinderSingh13 is offline Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 11 April 2018, 7:35 AM EDT
Location: Chennai
Posts: 2,715
Thanks: 609
Thanked 1,298 Times in 1,165 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 Unix and Linux 05-17-2017   -   Original Discussion by Zabo
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 17 April 2018, 8:12 AM EDT
Location: Loughborough
Posts: 1,256
Thanks: 375
Thanked 336 Times in 263 Posts
https://www.unix.com/shell-programmin...input-awk.html
    #4  
Old Unix and Linux 05-17-2017   -   Original Discussion by Zabo
Zabo's Unix or Linux Image
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 Unix and Linux 05-17-2017   -   Original Discussion by Zabo
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 April 2018, 2:49 PM EDT
Location: Saskatchewan
Posts: 22,636
Thanks: 1,172
Thanked 4,306 Times in 3,972 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 Unix and Linux 05-17-2017   -   Original Discussion by Zabo
Zabo's Unix or Linux Image
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 Unix and Linux 05-17-2017   -   Original Discussion by Zabo
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 April 2018, 2:49 PM EDT
Location: Saskatchewan
Posts: 22,636
Thanks: 1,172
Thanked 4,306 Times in 3,972 Posts
Erm, I meant, < "/dev/tty" , to force it to read from keyboard even when stdin is a file.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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:08 PM.