Sponsored Content
Full Discussion: Multiple input on same line?
Top Forums UNIX for Dummies Questions & Answers Multiple input on same line? Post 302500739 by losingit on Tuesday 1st of March 2011 11:42:53 AM
Old 03-01-2011
Multiple input on same line?

Hey all. I am trying to ask the user to enter two pieces of input that I will assign to variables all in one line. So for instance... I ask this:

"Please enter your name and age:"

With the following command I can do this on seperate lines. How can I do it all on one line?

Here is what I started with:

Code:
read -p  "Enter your name: " name
read -p  "Enter your age: " age

How can I do this on one line?

Using BASH
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

hi, am a new learner to shell programming. i have a script which will prompt for user to key in their name & display their name afterwards. script ===== echo "Pls enter your name:" read name echo "Your name is $name." output ===== Pls enter your name: Bob Your name is Bob. what... (2 Replies)
Discussion started by: newbie168
2 Replies

2. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

3. Shell Programming and Scripting

Input 2 files, calculate diffs line by line

Hi I am new to Unix and need help with the following (to you all I'm sure) simple task. I am trying to output the differences between previous snaphots of various filesystem sizes to the present sizes. I have three files (e.g.) : file 1 file 2 file 3 10 100 /var... (4 Replies)
Discussion started by: bigbuk
4 Replies

4. Shell Programming and Scripting

sed to read line by line and input into another file

I have two files. Fileone contains text string one text string two text string three Filetwo contains Name: Address: Summary: Name: Address: Summary: Name: Address: Summary: I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies

5. UNIX for Advanced & Expert Users

Input for multiple files.

Hi, I am trying to come up with a script, and would like the script to pick all the files place within a folder and interactive take my yes/no before processing within the command. Could you someone help me in modifying the script : #!/bin/bash # LDIF_FILES="File Name" for MY_FILE... (5 Replies)
Discussion started by: john_prince
5 Replies

6. Shell Programming and Scripting

awk, multiple files input and multiple files output

Hi! I'm new in awk and I need some help. I have a folder with a lot of files and I need that awk do something in each file and print a new file with the output. The input file name should be modified when I print the outpu files. Thanks in advance for help! :-) ciao (5 Replies)
Discussion started by: gabrysfe
5 Replies

7. Shell Programming and Scripting

Curl - input line by line from text file

Hi, I've got a text file with hundreds of lines I need to upload to an API via curl, one by one. The text file is like: 2012-08-01 10:45,124 2012-08-02 10:45,132 2012-08-03 10:45,114 I want to get curl to go through the text file sending a post for each line. like: curl --request... (0 Replies)
Discussion started by: emdeex
0 Replies

8. Shell Programming and Scripting

Command line multiple input

I'm using the below to get multiple input from USER and it is working, is there any better way in awk array single liner? echo "Enter Multiple input (Ctrl+d to exit)" >output while read A do echo "$A" >>output done (3 Replies)
Discussion started by: Roozo
3 Replies

9. Shell Programming and Scripting

Multiple file input

Once a time, I did see a way to multiply a file input in bash, but have forgotten how it was done. Eks. awk 'FNR==NR {a++;next} ($2 in a) {print $2}' file file Here you need file two times. I seen it some like this awk 'FNR==NR {a++;next} ($2 in a) {print $2}' 2&file (16 Replies)
Discussion started by: Jotne
16 Replies

10. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies
cat(1)							      General Commands Manual							    cat(1)

NAME
cat - Concatenates or displays files SYNOPSIS
cat [-benrstuv] file... | - The cat command reads each specified file in sequence and writes it to standard output. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: cat: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Omits line numbers from blank lines when -n is specified. If you specify the -b option, the -n option is automatically invoked with it. [Tru64 UNIX] Same as the -v option with a $ (dollar sign) character displayed at the end of each line. [Tru64 UNIX] Displays output lines preceded by line numbers, numbered sequentially from 1. [Tru64 UNIX] Replaces multiple consecutive empty lines with one empty line, so that there is never more than one empty line between lines containing characters. [Tru64 UNIX] Does not display a message if cat cannot find an input file. (Silent option.) [Tru64 UNIX] Same as the -v option, with the tab character printed as <Ctrl-i> (^I). Does not buffer output. Writes bytes from the input file to standard output without delay as each is read. [Tru64 UNIX] Displays nonprinting characters so that they are visible. OPERANDS
The name of the file to be displayed. If you do not specify a file or if you specify - (dash) instead of file, cat reads from standard input. The cat command accepts mul- tiple occurrences of - (dash) as a file argument. DESCRIPTION
[Tru64 UNIX] The cat command is frequently used with > (redirection symbol) to concatenate the specified files and write them to the spec- ified destination. (See CAUTIONS.) The cat command is also used with >> to append a file to another file. CAUTIONS
Do not redirect output to one of the input files using the > (redirection symbol). If you do this, you lose the original data in the input file because the shell truncates it before cat can read it. (See also the sh command.) EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To display the file notes, enter: cat notes If the file is longer than one screenful, it scrolls by too quickly to read. To display a file one page at a time, use the more com- mand. To concatenate several files, enter: cat section1.1 section1.2 section1.3 > section1 This creates a file named section1 that is a copy of section1.1 followed by section1.2 and section1.3. To suppress error messages about files that do not exist, enter: cat -s section2.1 section2.2 section2.3 > section2 If section2.1 does not exist, this command concatenates section2.2 and section2.3. Note that the message goes to standard error, so it does not appear in the output file. The result is the same if you do not use the -s option, except that cat displays the error message: cat: cannot open section2.1 You may want to suppress this message with the -s option when you use the cat command in shell procedures. To append one file to the end of another, enter: cat section1.4 >> section1 The >> in this command specifies that a copy of section1.4 be added to the end of section1. If you want to replace the file, use a single > symbol. To add text to the end of a file, enter: cat >> notes Get milk on the way home <Ctrl-d> Get milk on the way home is added to the end of notes. With this syntax, the cat command does not display a prompt; it waits for you to enter text. Press the End-of-File key sequence (<Ctrl-d> above) to indicate you are finished. To concatenate several files with text entered from the keyboard, enter: cat section3.1 - section3.3 > section3 This concatenates section3.1, text from the keyboard, and section3.3 to create the file section3. To concatenate several files with output from another command, enter: ls | cat section4.1 - > section4 This copies section4.1, and then the output of the ls command to the file section4. To get two pieces of input from the terminal (when standard input is a terminal) with a single command invocation, enter: cat start - middle - end > file1 If standard input is a regular file, however, the preceding command is equivalent to the following: cat start - middle /dev/null end > file1 This is because the entire contents of the file would be consumed by cat the first time it saw - (dash) as a file argument. An End- of-File condition would then be detected immediately when - (dash) appeared the second time. ENVIRONMENT VARIABLES
The following environment variables affect the execution of cat: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: more(1), ksh(1), pack(1), pg(1), pr(1), Bourne shell sh(1b), POSIX shell sh(1p) Standards: standards(5) cat(1)
All times are GMT -4. The time now is 11:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy