Sponsored Content
Top Forums Shell Programming and Scripting How to remove the text between all curly brackets from text file? Post 303019878 by MadeInGermany on Monday 9th of July 2018 01:38:59 PM
Old 07-09-2018
Quote:
Originally Posted by wbport
Do you have the option to output your PGN file without computer annotation?
Pardon? What is PGN?
--
Another sed solution that will save some memory, by only reading the needed lines into the input buffer.
Written as a multi-liner (better readable):
Code:
sed '
 :loop
 /{/{
  s/{[^{}]*}//
  t loop
  $!N; $!b loop
 }
' infile

This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing text between two square brackets

hi guys, i'm writing a script that looks for a unquie id in a file and replaces a string between two square brackets on the same line as the unquie id: ....... ....... 0001 zz 43242 replace this text] name 0002 sd 65466 UK] country ....... ....... how can i find line with id 0001... (6 Replies)
Discussion started by: zaff
6 Replies

2. Shell Programming and Scripting

Delete text between square brackets and also delete those square brackets using sed or awk

Hi All, I have a text file which looks like this: computer programming systems engineering I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this: computer programming systems engineering I am using... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

3. Shell Programming and Scripting

Extract text between two square [..] brackets

Hi All, After searching about this, I could find some solutions but I am not sure why it is not working in my case. I have a text file with contents between two square brackets. The text file looks like this: Use tags when you post any code so others can easily read your code. You can... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

4. Shell Programming and Scripting

Remove text between brackets

How can I use bash to remove all text between "<" and ">" in a file? (1 Reply)
Discussion started by: locoroco
1 Replies

5. Shell Programming and Scripting

Shell Variable in Curly Brackets Returns Empty Value

Hello Team, I have a script which will grep for a time from a file. I have following code to grep for a time in a file. node=`hostname` current_date=`date` file11=weblogic.log next_date=`date '+%b %e, %Y'` next_date_time11=`grep -i "${#next_date}" ${file11}| tail -1 | awk... (3 Replies)
Discussion started by: coolguyamy
3 Replies

6. Shell Programming and Scripting

Extract the text between the nth occurrence of square brackets

Please can someone help with this? I have a file with lines as follows: word1 word2 word3 word4 word5 word6 word7 word8 word1 word2 word3 word4 word5 word6 word7 word8 word1 word2 word3 word4 word5 word6 word7 word8 word1 word2 word3 word4 word5 word6 word7 word8 When I use the... (7 Replies)
Discussion started by: Subhadeep_Sahu
7 Replies

7. Shell Programming and Scripting

Remove multiline text between brackets

I have some text in a file like so This is {the first day of} my life. What I would like as output is This is my life. Any text between the curly braces is removed. In the forums I've found statements like sed 's/<*>//g' but the problem is that I think that... (12 Replies)
Discussion started by: climatron
12 Replies

8. Shell Programming and Scripting

Curly brackets converted to unicode in script

Is this a bash or wget issue? GNU bash, version 4.4.0(1)-release (x86_64-slackware-linux-gnu) GNU Wget 1.18 built on linux-gnu. If I run wget -O file localhost/{2..4} from the command line, it will download pages 2 to 4 and concatenate them to file - which is what I want. If I put this in a... (4 Replies)
Discussion started by: Ray-V
4 Replies

9. UNIX for Beginners Questions & Answers

Sort a text file based on names in square brackets

Hi all, I have a text file similar to this: Text More text Etc Stuff That Is Needed Etc Etc This contains over 70 entries and each entry has several lines of text below the name in square brackets. (5 Replies)
Discussion started by: Scally
5 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
IO::Async::Socket(3pm)					User Contributed Perl Documentation				    IO::Async::Socket(3pm)

NAME
"IO::Async::Socket" - event callbacks and send buffering for a socket filehandle SYNOPSIS
use IO::Async::Socket; use IO::Async::Loop; my $loop = IO::Async::Loop->new; $loop->connect( host => "some.host.here", service => "echo", socktype => 'dgram', on_connected => sub { my ( $sock ) = @_; my $socket = IO::Async::Socket->new( handle => $sock, on_recv => sub { my ( $self, $dgram, $addr ) = @_; print "Received reply: $dgram ", $loop->stop; }, on_recv_error => sub { my ( $self, $errno ) = @_; die "Cannot recv - $errno "; }, ); $loop->add( $socket ); $socket->send( "A TEST DATAGRAM" ); }, on_resolve_error => sub { die "Cannot resolve - $_[0] "; }, on_connect_error => sub { die "Cannot connect "; }, ); $loop->run; DESCRIPTION
This subclass of IO::Async::Handle contains a socket filehandle. It provides a queue of outgoing data. It invokes the "on_recv" handler when new data is received from the filehandle. Data may be sent to the filehandle by calling the "send" method. It is primarily intended for "SOCK_data" or "SOCK_RAW" sockets; for "SOCK_STREAM" sockets an instance of IO::Async::Stream is probably more appropriate. EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_recv $data, $addr Invoke on receipt of a packet, datagram, or stream segment. The "on_recv" handler is invoked once for each packet, datagram, or stream segment that is received. It is passed the data itself, and the sender's address. on_recv_error $errno Optional. Invoked when the "recv" method on the receiving handle fails. on_send_error $errno Optional. Invoked when the "send" method on the sending handle fails. The "on_recv_error" and "on_send_error" handlers are passed the value of $! at the time the error occured. (The $! variable itself, by its nature, may have changed from the original error by the time this handler runs so it should always use the value passed in). If an error occurs when the corresponding error callback is not supplied, and there is not a subclass method for it, then the "close" method is called instead. on_outgoing_empty Optional. Invoked when the sending data buffer becomes empty. PARAMETERS
The following named parameters may be passed to "new" or "configure": read_handle => IO The IO handle to receive from. Must implement "fileno" and "recv" methods. write_handle => IO The IO handle to send to. Must implement "fileno" and "send" methods. handle => IO Shortcut to specifying the same IO handle for both of the above. on_recv => CODE on_recv_error => CODE on_outgoing_empty => CODE on_send_error => CODE autoflush => BOOL Optional. If true, the "send" method will atempt to send data to the operating system immediately, without waiting for the loop to indicate the filehandle is write-ready. recv_len => INT Optional. Sets the buffer size for "recv" calls. Defaults to 64 KiB. recv_all => BOOL Optional. If true, repeatedly call "recv" when the receiving handle first becomes read-ready. By default this is turned off, meaning at most one fixed-size buffer is received. If there is still more data in the kernel's buffer, the handle will stil be readable, and will be received from again. This behaviour allows multiple streams and sockets to be multiplexed simultaneously, meaning that a large bulk transfer on one cannot starve other filehandles of processing time. Turning this option on may improve bulk data transfer rate, at the risk of delaying or stalling processing on other filehandles. send_all => INT Optional. Analogous to the "recv_all" option, but for sending. When "autoflush" is enabled, this option only affects deferred sending if the initial attempt failed. The condition requiring an "on_recv" handler is checked at the time the object is added to a Loop; it is allowed to create a "IO::Async::Socket" object with a read handle but without a "on_recv" handler, provided that one is later given using "configure" before the stream is added to its containing Loop, either directly or by being a child of another Notifier already in a Loop, or added to one. METHODS
$socket->send( $data, $flags, $addr ) This method adds a segment of data to be sent, or sends it immediately, according to the "autoflush" parameter. $flags and $addr are optional. If the "autoflush" option is set, this method will try immediately to send the data to the underlying filehandle, optionally using the given flags and destination address. If this completes successfully then it will have been sent by the time this method returns. If it fails to send, then the data is queued as if "autoflush" were not set, and will be flushed as normal. SEE ALSO
o IO::Handle - Supply object methods for I/O handles AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Socket(3pm)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy