Sponsored Content
Operating Systems Linux Remove newline in middle of string Post 302777419 by Yoda on Friday 8th of March 2013 12:36:53 AM
Old 03-08-2013
Explanation:
Code:
awk '
/^>/ {                                  # If current record starts with > ( /^</ )
        $0 = (NR > 1 ? RS $0 : $0)      # If current record number is greater 1 (NR > 1) set it to newline followed by current record (RS $0)
        ORS = RS                        # Set Output Record Separator to Record Separator (ORS = RS) [ RS is newline by default ]
}

! />/ {                                 # If current record does not contains pattern > ( !/>/ )
        ORS = ""                        # Set Output Record Separator to "" (ORS = "")
}

END {                                   # END Block
        printf "\n"                     # Print newline
} 1                                     # 1 == true, so print current record
' file

Note: ORS, RS, NR are special variables in awk. Please check the awk manual pages for further reference. I hope this helps.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

add a string in the middle of the file

i want to add a string in a very top of a file without using VI or SED or AWK this is what ive done: (echo '0a'; echo 'LINE OF TEXT'; echo '.'; echo 'wq') | ed -s myfile to add astrng right in the middle i could have count the lines of the file and just chenge the address. ... (6 Replies)
Discussion started by: ciroredz
6 Replies

2. Shell Programming and Scripting

stripping certain characters in at the middle of a string

I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach: line=see@hear|touch templine=${line#*@} #removed "see@" echo ${templine%%\|*} #removed... (4 Replies)
Discussion started by: mcoblefias
4 Replies

3. Shell Programming and Scripting

how to remove all tabs and newline (\n)

how to remove all tabs and newline (\n) from the exicting file (2 Replies)
Discussion started by: pvr_satya
2 Replies

4. UNIX for Dummies Questions & Answers

Add string to middle of a file

Hi, I want to write a script that takes a file and a string as params and adds the string to the middle line of the file. Also, I want to output the results back to the original file passed without using temp files. I am very much new to UNIX so this is all a little like black magic to me at... (15 Replies)
Discussion started by: Chiefos
15 Replies

5. UNIX for Dummies Questions & Answers

Is it possible to grep with a newline in the middle of an expression?

I'm hoping that there is a way to do this. I'm sure I won't be able to get the answer I need on the deadline I need it...but at least I'll learn how to solve this problem. I have a file that looks like this: (00:14:25\$ head -27 QNHDSPACEDVR Name: PollDhctAVFSInfo 00:0F:21:4B:00:6A Name:... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

6. UNIX for Dummies Questions & Answers

Splitting a string and putting another string in the middle?

Hello all! I'm trying to put together a small script that will take in a file name and attach a datestamp to the end of it (but before the file type extension). To illustrate... Before: filename.txt anotherfilename.txt After: filename_20090724.txt anotherfilename_20090724.txt ... (7 Replies)
Discussion started by: jisoo411
7 Replies

7. Shell Programming and Scripting

remove newline between two string with sed command in unix shellscript

I have a file (test.dat) which contains data like this 459|199811047|a |b |shan kar|ooty| 460|199811047|a |bv |gur u|cbe| but I need it like: 459|199811047|a |b |shankar|ooty| 460|199811047|a |b |guru|cbe| While reading the data from this file, I don't want to remove newline from the end of... (4 Replies)
Discussion started by: jcrshankar
4 Replies

8. Shell Programming and Scripting

Remove last newline character..

Hi all.. I have a text file which looks like below: abcd efgh ijkl (blank space) I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file. I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies

9. UNIX for Dummies Questions & Answers

Map a string in a the middle of a record

Hi Folks! I hope you can help me figure this out. I need to print a record which contains the contents of a config file. The contents of the config file should be found within the 21st and the 30th position of the fixed width reference file. Config File: aaaa bbbb cccc Reference... (3 Replies)
Discussion started by: kokoro
3 Replies

10. UNIX for Dummies Questions & Answers

Using sed to remove spaces from middle of the line

Hi, I need to correct href portion of the lines to edit out spaces from the line starting with position "<a href=" and ending at "target=" Below are 2 examples of extra space added by the server: <td width=251 colspan=9 rowspan=22> <font size=2 face="courier"><tt><style>{font:7pt Courier ... (4 Replies)
Discussion started by: friedmi
4 Replies
BYZANZ-RECORD(1)					      General Commands Manual						  BYZANZ-RECORD(1)

NAME
byzanz-record - record your desktop session to an animated GIF SYNOPSIS
byzanz-record [options] FILENAME DESCRIPTION
Byzanz records your desktop session to an animated GIF. You can record your entire screen, a single window, or an arbitrary region. byzanz-record allows you to make recordings from the command line. Graphical users may want to use the panel applet instead. OPTIONS
Application Options: -d, --duration=SECS Duration of animation (default: 10 seconds) --delay=SECS Delay before start (default: 1 second) -c, --cursor Record mouse cursor -a, --audio Record audio from the default input device. This only works if the output format supports it and will otherwise cause an error. -x, --x=PIXEL X coordinate of rectangle to record -y, --y=PIXEL Y coordinate of rectangle to record -w, --width=PIXEL Width of recording rectangle -h, --height=PIXEL Height of recording rectangle -v, --verbose Be verbose --display=DISPLAY X display to use Help Options: -?, --help Show help options --help-gtk Show GTK+ Options --help-all Show all help options OUTPUT FILE
After byzanz-record is finished, the recording is written to FILENAME. The format is determined by the filename extension. The following formats are supported: gif Record to an animated GIF image. Use this if you want to record a mostly static screen with a limited amount of colors, such as using a file manager or an office application. This is the default and will be used if an unrecognized extension is used. ogg, ogv Record to an Ogg Theora video. This format supports audio. Use this if you want to record dynamic contents, such as video playback. flv Record to a Flash Screen video. This recording method is lossless. Use it if you want to postprocess the file in other applications. byzanz Record to Byzanz' internal debugging format. This is useful for benchmarking Byzanz or if you want to convert the recording to mul- tiple formats later. You can use byzanz-playback(1) to convert the file. SEE ALSO
byzanz-playback(1) AUTHOR
Byzanz was written by Benjamin Otte <otte@gnome.org>. This manual page was last updated for version 0.2.1. BYZANZ-RECORD(1)
All times are GMT -4. The time now is 05:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy