Sponsored Content
Top Forums Shell Programming and Scripting Read 2 input and produce it in single ouput? Post 302936946 by type8code0 on Monday 2nd of March 2015 07:10:49 AM
Old 03-02-2015
Quote:
Originally Posted by Scrutinizer
You're welcome... You could adjust the shell loop like so, leaving out the first input file and reading from the terminal instead..
Code:
while 
  printf "Enter new group name : "
  read service_group
do
  printf "You entered: %s\n" "$service_group"
  printf "create service_group %s\n" "$service_group"
  while read port
  do
    printf "create service_group %s '' services:tcp%s\n" "$service_group" "$port"
  done < file2
done

This is perfect. Thanks again. SmilieSmilieSmilieSmilie

Quick question, how to stop this loop besides using combination of Ctrl + C?

Code:
type8code0@box:~/dbedit$ ./test
Enter new group name : XYZ
You entered: XYZ
create service_group XYZ
create service_group XYZ '' services:tcp22
create service_group XYZ '' services:tcp80
create service_group XYZ '' services:tcp443
Enter new group name :
You entered:
create service_group
create service_group  '' services:tcp22
create service_group  '' services:tcp80
create service_group  '' services:tcp443
Enter new group name : ABC
You entered: ABC
create service_group ABC
create service_group ABC '' services:tcp22
create service_group ABC '' services:tcp80
create service_group ABC '' services:tcp443
Enter new group name :

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

single input shell script?

hey, i'm trying to write a shell script which accepts: operand operator operand then, the script would see which operator it is (using case) and calculate it... but i dont know how to do it correctly with $1 $2 $3... (eliminating accepting separate inputs) (1 Reply)
Discussion started by: quipy
1 Replies

2. Shell Programming and Scripting

Consecutive spaces within input being converted to single space

I'm reading from a file that is semi-colon delimited. One of the fields contains 2 spaces separating the first and last name (4th field in - "JOHN<space><space> DOE"): e.g. TORONTO;ONTARIO;1 YONGE STREET;JOHN DOE;CANADA When I read this record and either echo/print to screen or write to... (4 Replies)
Discussion started by: NinersFan
4 Replies

3. Shell Programming and Scripting

read single chars

This reads single keystrokes and produces an output: #! /bin/bash while : ; do read -s -n 1 >/dev/null 2>&1 echo ${REPLY} done | awk '{print}' This second one don't. Even though these examples make no sense; the real code is more complicated. Who knows what the problem is... (2 Replies)
Discussion started by: elbrand
2 Replies

4. Shell Programming and Scripting

Two Input Lines Into Single Output Line (CSV)

Hi all, My search karate must be weak because I'm about certain something very like this has been asked and answered here many times. I'll give you the exact scenario I've wasted a few hours of my Saturday on: :wall: I'm trying to read through a very large number (~200) of router and... (28 Replies)
Discussion started by: svermill
28 Replies

5. Shell Programming and Scripting

Input two variable on single line

Can we input two variable on single line that separate by space example user input "list jpg" it will list all jpg files in current directory (3 Replies)
Discussion started by: guidely
3 Replies

6. Shell Programming and Scripting

Append ouput in a single line

Hi Guys, I need to append some data to a new file, but i need to make sure that when i use to >> command again.I dont go to the new line. i append the data on the same line. Please help regarding the same. Thanks in advance..!!! (3 Replies)
Discussion started by: jaituteja
3 Replies

7. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

8. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

9. Shell Programming and Scripting

How do I split a single-line input into five lines?

Example input: John:Shepherd:770-767-4040:U.S.A:New York Mo Jo:Jo Jo: 666-666-6666:U.S.A:Townsville Expected Output: First Name: John Last Name: Shepherd Phone Number: 770-767-4040 Country: U.S.A State: New York First Name: Mo Jo Last Name: Jo Jo Phone Number: 666-666-6666... (10 Replies)
Discussion started by: Camrikron
10 Replies

10. Shell Programming and Scripting

Read input from Keyboard, do not proceed if no input

Hi, I am working on a script, which requests users to enter input. Ex: read -p "Please enter your email id:" email I don't want users skipping this entry, this has to be mandatory.I dont want to proceed without input. I can do a check if variable $email is empty and proceed if not.But, i... (7 Replies)
Discussion started by: aravindadla
7 Replies
SERVICES(5)						      BSD File Formats Manual						       SERVICES(5)

NAME
services -- service name data base DESCRIPTION
The services file contains information regarding the known services available in the DARPA Internet. For each service a single line should be present with the following information: official service name port number protocol name aliases Items are separated by any number of blanks and/or tab characters. The port number and protocol name are considered a single item; a ``/'' is used to separate the port and protocol (e.g. ``512/tcp''). A ``#'' indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Service names may contain any printable character other than a field delimiter, newline, or comment character. INTERACTION WITH DIRECTORY SERVICES
Processes generally find service records using one of the getservent(3) family of functions, or using getaddrinfo(3). On Mac OS X, these functions interact with the DirectoryService(8) daemon, which reads the /etc/services file as well as searching other directory information services to determine service name, protocol, and port information. FILES
/etc/services SEE ALSO
getservent(3), getaddrinfo(3), DirectoryService(8) HISTORY
The services file format appeared in 4.2BSD. 4.2 Berkeley Distribution June 5, 1993 4.2 Berkeley Distribution
All times are GMT -4. The time now is 06:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy