Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to convert multilines to single lines Post 302409100 by mirfan on Wednesday 31st of March 2010 07:04:19 AM
Old 03-31-2010
Shell Script to convert multilines to single lines

Hi,

I need to create an script which reads multi lines and convert it to single line or enter escape sequence at end "\".
e.g.

Code:
#!/bin/sh

echo -e "provide me query to run"
read query 

create table test(
id int(11),
name char);

echo $query

But it's failing because of multi line i need output as follows:

Code:
create table test(id int(11),name char);

For this i tried

Code:
read query '+'  \

but it fails. Is there any way to do it means read parse multi lines into single line ?

Thank you.

Last edited by Franklin52; 03-31-2010 at 08:08 AM.. Reason: Please use code tags!
 

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

Single Instance of a Shell Script

Hi, I have a shell script. What should I do to allow only single instance of the script to be run by a user at a time. That is, Only one user can run that script at a given point of time. Please help.. Its very important for my project Thanks in advance (4 Replies)
Discussion started by: pathanjalireddy
4 Replies

3. Shell Programming and Scripting

here-doc convert 2 script convert to single script?

I have my main script calling another script to retrive a "ls -alt" of a directory that's located in a remote location I'm sftping into. main.sh #!/bin/ksh getLS.sh > output.txt getLS.sh #!/bin/sh /home<..>/sftp <host@ip> <<! cd /some/dir/Log ls -alt quit ! Basically I'd like to be... (2 Replies)
Discussion started by: yongho
2 Replies

4. Shell Programming and Scripting

Run a single script in different shell

Hi All, I am new in UNIX.I have a situation here.:confused: I have a script which have to be run in every shell (like KSH,BASH,CSH). Script may be any thing. But i don't know how to do it.Because the syntax of every shell may be different. Please advise.. Thanks for your kind advise in... (5 Replies)
Discussion started by: jdash.ps
5 Replies

5. Shell Programming and Scripting

how to convert a shell script to a php script for displaying next word after pattern match

I have a shell script which I made with the help of this forum #!/bin/sh RuleNum=$1 cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}' Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Discussion started by: sb245
0 Replies

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

7. Shell Programming and Scripting

convert to shell script

how to convert these code to shell script #include<stdio.h> #include<conio.h> main() { int i,j,a=0,b=0,c=0,f,t,al,ta; int a1, max, n, n1,p,k=0; printf(“\n enter no.of resources”); scanf(“%d”,n1); printf(“\nenter the max no .of resources for each type”); for(i=0;i<n1;i++)... (4 Replies)
Discussion started by: syah
4 Replies

8. Shell Programming and Scripting

Convert Singleline to Multilines

Hi All, Could you please help to get the below output: Input: J1,ELLA_1,ISDR,JJK,TRS J2,ROSTER,JACK J3,HUP ... ... ... Output: J1,ELLA_1 J1,ISDR J1,JJK J1,TRS (3 Replies)
Discussion started by: unme
3 Replies

9. Shell Programming and Scripting

Shell script to convert IP range csv into a list of single IP's

Hi All, I am looking for some help to convert a csv with IP ranges in.. in the format e.g. 1.1.1.2, 1.1.1.5 2.1.1.10, 2.1.1.20 and would be looking to output as follows: 1.1.1.2 1.1.1.3 1.1.1.4 1.1.1.5 2.1.1.10 2.1.1.11 etc etc up to 2.1.1.20 I have tried a few google... (4 Replies)
Discussion started by: zippyzip
4 Replies

10. UNIX for Beginners Questions & Answers

Merge multi-lines into one single line using shell script or Linux command

Hi, Can anyone help me for merge the following multi-line log which beginning with a " and line ending with ": into one line. *****Original Log***** 087;2008-12-06;084403;"mc;;SYHLR6AP1D\LNZW;AD-703;1;12475;SYHLR6AP1B;1.1.1.1;0000000062;HGPDI:MSISDN=12345678,APNID=1,EQOSID=365;... (3 Replies)
Discussion started by: rajeshlinux2010
3 Replies
YAP(1)							      General Commands Manual							    YAP(1)

NAME
yap, more - yet another pager SYNOPSIS
yap [ -cnuq ] [ -n ] [ +command ] [ name ... ] DESCRIPTION
Yap is a program allowing the user to examine a continuous text one screenful at a time on a video display terminal. It does so by pausing after each screenful, waiting for the user to type a command. The commands are enumerated later. Yap's main feature is, that it can page both forwards and backwards, even when reading from standard input. The command line options are: -n An integer which is the size (in lines) of a page (the initial page-size. -c Normally, yap will display each page by beginning at the top of the screen and erasing each line just before it displays on it. If your terminal cannot erase a line, yap will clear the screen before it displays a page. This avoids scrolling the screen, making it easier to read while yap is writing. The -c option causes yap to scroll the screen instead of beginning at the top of the screen. This is also done if your terminal cannot either erase a line or clear the screen. -u Normally, yap handles underlining such as produced by nroff in a manner appropriate to the particular terminal: if the terminal can perform underlining well (t.i., the escape sequences for underlining do not occupy space on the screen), yap will underline under- lined information in the input. The -u option supresses this underlining. -n Normally, yap also recognises escape sequences for stand-out mode or underlining mode in the input, and knows how much space these escape sequences will occupy on the screen, so that yap will not fold lines erroneously. The -n option supresses this pattern matching. -q This option will cause yap to exit only on the "quit" command. +command command is taken to be an initial command to yap. Yap uses the termcap(5) database to determine the terminal capabilities and the default page-size. It examines the $TERM environment vari- able to identify the terminal type. If $TERM is not set, it defaults to dumb. Yap Also examines the $TERMCAP environment variable to locate the termcap(5) database. If $TERMCAP is not set, it defaults to /etc/termcap. Yap looks in the $YAP environment variable to pre-set flags. For instance, if you prefer the -c mode of operation, just set the $YAP envi- ronment variable to -c. The commands of yap can be bound to sequences of keystrokes. The environment variable $YAPKEYS may contain the bindings in the form of a list of colon-separated `name=sequence' pairs. The name is a short mnemonic for the command, the sequence is the sequence of keystrokes to be typed to invoke the command. This sequence may contain a ^X escape, which means control-X, and a X escape, which means X. The latter can be used to get the characters `^', `' and `:' in the sequence. There are two keymaps available, the default one and a user-defined one. You can switch between one and the other with the change keymap command. The yap commands are described below. The mnemonics for the commands are given in parentheses. The default key sequences (if any) are given after the mnemonic. Every command takes an optional integer argument, which may be typed before the command. Some commands just ignore it. The integer argument is referred to as i. Usually, if i is not given, it defaults to 1. visit previous file (bf) P Visit the i-th previous file given in the command line. scroll one line up or go to line (bl) ^K or k If i is not given, scroll one line up. Otherwise, i will be interpreted as a line number. A page starting with the line indicated will then be displayed. bottom (bot) l or $ Go to the last line of the input. display previous page (bp) - Display the previous page, consisting of i lines, (or page-size lines if no argument is given). display previous page and set pagesize (bps) Z Display the previous page, consisting of i lines, (or page-size lines if no argument is given). If i is given, the page-size is set to i. scroll up (bs) ^B Scroll up i lines (or scroll-size lines if i is not given. Initially, the scroll-size is 11). search backwards for pattern (bse) ? Search backwards for the i-th occurrence of a regular expression which will be prompted for. If there are less than i occurrences of the expression, the position in the file remains unchanged. Otherwise, a page is displayed, starting two lines before the place where the expression was found. The user's erase and kill characters may be used to edit the expression. Erasing back past the first character cancels the search command. Note: Some systems do not have regex(3). On those systems, searches are still supported, but regular expressions are not. skip lines backwards (bsl) S Skip i lines backwards and display a page. skip pages backwards (bsp) F Skip i pages backwards and display a page. scroll up and set scrollsize (bss) b Scroll up i lines (or scroll-size lines if i is not given. If i is given, the scroll-size is set to i. change key map (chm) ^[ Change from the current key map to the other (if there is one). exchange current page and mark (exg) x Set the mark to the current page, and display the previously marked page. visit next file (ff) N Visit the i-th next file given in the command line. scroll one line down or go to line (fl) ^J or ^M or j If i is not given, scroll one line down. Otherwise, i will be interpreted as a line number. A page starting with the line indicated will then be displayed. display next page (fp) <space> Display the next page, consisting of i lines, (or page-size lines if no argument is given). display next page and set pagesize (fps) z Display the next page, consisting of i lines, (or page-size lines if no argument is given). If i is given, the page-size is set to i. scroll down (fs) ^D Scroll down i lines (or scroll-size lines if no argument is given). search forwards for pattern (fse) / Search forwards for the i-th occurrence of a regular expression which will be prompted for. If there are less than i occurrences of the expression, the position in the file remains unchanged. Otherwise, a page is displayed, starting two lines before the place where the expression was found. The user's erase and kill characters may be used to edit the expression. Erasing back past the first character cancels the search command. Note: Some systems do not have regex(3). On those systems, searches are still supported, but regular expressions are not. skip lines forwards (fsl) s Skip i lines and display a page. skip pages forwards (fsp) f Skip i pages and display a page. scroll down and set scrollsize (fss) d Scroll down i lines (or scroll-size lines if i is not given. If i is given, the scroll-size is set to i. help (hlp) h Give a short description of all commands that are bound to a key sequence. set a mark (mar) m Set a mark on the current page. repeat last search (nse) n Search for the i-th occurrence of the last regular expression entered, in the direction of the last search. repeat last search in other direction (nsr) r Search for the i-th occurrence of the last regular expression entered, but in the other direction. quit (qui) Q or q Exit from yap. redraw (red) ^L Redraw the current page. repeat (rep) . Repeat the last command. This does not always make sense, so not all commands can be repeated. shell escape (shl) ! Invoke the shell with a command that will be prompted for. In the command, the characters `%' and `!' are replaced with the current file name and the previous shell command respectively. The sequences `\%' and `!' are replaced by `%' and `!' respectively. The user's erase and kill characters can be used to edit the command. Erasing back past the first character cancels the command. pipe to shell command (pip) | Pipe the current input file into a shell command that will be prompted for. The comments given in the description of the shell escape command apply here too. go to mark (tom) ' Display the marked page. top (top) ^^ Display a page starting with the first line of the input. visit file (vis) e Visit a new file. The filename will be prompted for. If you just type a return, the current file is revisited. write input to a file (wrf) w Write the input to a file, whose name will be prompted for. The commands take effect immediately, i.e., it is not necessary to type a carriage return. Up to the time when the command sequence itself is given, the user may give an interrupt to cancel the command being formed. AUTHOR
Ceriel J.H. Jacobs FILES
/etc/termcap Terminal capabilities data base SEE ALSO
termcap(5), regex(3). BUGS
Yap will find your terminal very stupid and act like it, if it has no way of placing the cursor on the home position, or cannot either erase a line or insert one. In lines longer than about 2000 characters, a linefeed is silently inserted. The percentage, given in the prompt when yap reads from a file (and knows it), is not always very accurate. local YAP(1)
All times are GMT -4. The time now is 12:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy