Sponsored Content
Top Forums Shell Programming and Scripting How do I split a single-line input into five lines? Post 302894011 by ahamed101 on Sunday 23rd of March 2014 05:25:23 AM
Old 03-23-2014
Well, it works for me. Did you omit the new line in the code? Are you using the exact code I have given? which is your OS?

Code:
root@maximus:/tmp# awk '
   BEGIN{ fmt="%20s%20s\n" }
   function prt()
   {
     printf(fmt, "First Name:", data[1])
     printf(fmt, "Country:", data[4])
     printf(fmt, "Last Name:", data[2])
     printf(fmt, "Phone Number:", data[3])
     printf(fmt, "Country:", data[4])
     printf(fmt, "State:", data[5])
     printf("\n")
   }
   { split($0, data, ":"); prt() }'  infile

         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
            Country:               U.S.A
              State:          Townsville

 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Break lines up into single lines after each space in every line

It sounds a bit confusing but what I have is a text file like the example below (without the Line1, Line2, Line3 etc. of course) and I want to move every group of characters into a new line after each space. Example of text file; line1 .digg-widget-theme2 ul { background: rgb(0, 0, 0) none... (7 Replies)
Discussion started by: lewk
7 Replies

3. Shell Programming and Scripting

split single line into two line or three lines

Dear All, I want to split single line into two line or three lines wherever “|” separated values comes using Input line test,DEMTEMPUT20100404010012,,,,,,,,|0070086|0070087, output shoule be test,DEMTEMPUT20100404010012,,,,,,,,0070086, test,DEMTEMPUT20100404010012,,,,,,,,0070087, (14 Replies)
Discussion started by: arvindng
14 Replies

4. Shell Programming and Scripting

Split the single file lines into multiple files

Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow. INPUT: Input file name A 1 2 3 4 5 6 7 8 9 ........100 Output: 4 output files (x,y,z,w) File x should contains (Skip 4 lines)... (15 Replies)
Discussion started by: subbarao25
15 Replies

5. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

6. 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

7. Shell Programming and Scripting

Split the a single line into two

Hi all, I wanted to split a single line into two line. For example: A/B/C 10 i want this output var1 = A/B/C var2 = 10 How do i get this. (2 Replies)
Discussion started by: ch33ry
2 Replies

8. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

9. 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

10. Shell Programming and Scripting

Split: File into multiple and keeping the same 3 lines from input into all output files

The following code will split the infile into multiple files. However, I need it to insert the same first 3 lines from the original input file into each splitted file. How do I modify my script below to do so: print -n "Enter file name to split? " ; read infile if then echo "Invalid file... (4 Replies)
Discussion started by: mrn6430
4 Replies
curs_printw(3X) 														   curs_printw(3X)

NAME
printw, wprintw, mvprintw, mvwprintw, vwprintw, vw_printw - print formatted output in curses windows SYNOPSIS
#include <curses.h> int printw(char *fmt [, arg] ...); int wprintw(WINDOW *win, char *fmt [, arg] ...); int mvprintw(int y, int x, char *fmt [, arg] ...); int mvwprintw(WINDOW *win, int y, int x, char *fmt [, arg] ...); #include <varargs.h> int vwprintw(WINDOW *win, char *fmt, varglist); int vw_printw(WINDOW *win, char *fmt, varglist); DESCRIPTION
The printw, wprintw, mvprintw and mvwprintw routines are analogous to printf [see printf(3S)]. In effect, the string that would be output by printf is output instead as though waddstr were used on the given window. The vwprintw routine is analogous to vprintf [see printf(3S)] and performs a wprintw using a variable argument list. The third argument is a va_list, a pointer to a list of arguments, as defined in <varargs.h>. RETURN VALUE
Routines that return an integer return ERR upon failure and OK (SVr4 only specifies "an integer value other than ERR") upon successful com- pletion. PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. The function vwprintw is marked TO BE WITHDRAWN, and is to be replaced by a function vw_printw using the <stdarg.h> interface. SEE ALSO
curses(3X), printf(3S), vprintf(3S) curs_printw(3X)
All times are GMT -4. The time now is 09:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy