Sponsored Content
Top Forums Shell Programming and Scripting How to remove the text between all curly brackets from text file? Post 303019845 by prvnrk on Sunday 8th of July 2018 04:07:35 PM
Old 07-08-2018
How to remove the text between all curly brackets from text file?

Hello experts,

I have a text file with lot of curly brackets (both opening { & closing } ). I need to delete them alongwith the text between opening & closing brackets' pair.

For ex: Input:-
Code:
59. Rh1 Qe4 {(Qf5-e4 Qd8-g8+ Kg6-f5
Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+ Qe6-g6 Qh7-h3+ Kf5-f6
Qh3-c3+ Kf6-f7 Qc3-b3+ Kf7-f6 Qb3-b6+ Kf6-f7 Qb6-b7+ Kf7-f6 Qb7-c6+ Kf6-f7
Qc6-d7+ Kf7-f6 Rh1-h8 Qg6-g7 Qd7-c6+ Kf6-f5 Qc6xc5+ Bf4-e5 Rh8-h7 Qg7-g6
Qc5-c2+ Kf5-f6 Qc2-c6+ Kf6-f5 Qc6-f3+ Be5-f4 Qf3-h3+ g5-g4 Qh3-d3+ Kf5-f6
Qd3-d8+ Kf6-f5 Qd8-d5+ Kf5-f6 Rh7-h8 Bf4-e5 Rh8-f8+ Kf6-e7 Qd5-d8+ Ke7-e6
Rf8-e8+ Qg6xe8 Qd8xe8+ Ke6-f5 Qe8-d7+ Kf5-g5 Qd7-d8+ Kg5-f5 Qd8xa5 Kf5-f4
Qa5-d2+ Kf4-g3 Qd2-e3+ Kg3-g2 Qe3xe5 g4-g3) -132.53/42 7} 60. Qg8+
{(Qd8-g8+ Kg6-f5 Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+
Qe6-g6 Qh7-h3+ Kf5-f6 Qh3-c3+ Kf6-f7 Qc3-b3+ Kf7-f6 Qb3-b6+ Kf6-g7 Qb6-b7+
Kg7-f6 Qb7-c6+ Kf6-g7 Qc6-d7+ Kg7-f6 Rh1-h8 Qg6-g7 Qd7-c6+ Kf6-f5 Qc6xc5+
Bf4-e5 Rh8-h7 Qg7-g6 Qc5-f2+ Kf5-g4 Qf2-e2+ Kg4-f5 Qe2-d3+ Kf5-f6 Qd3-f3+
Be5-f4 Qf3-c6+ Kf6-f5 Qc6-c8+ Kf5-e5 Rh7-e7+ Ke5-d5 Qc8-d7+ Bf4-d6 Qd7-b5+
Kd5-d4 Qb5-c6 Bd6xe7 Qc6xg6 Kd4-e5 Qg6-e8 Ke5-d6 Qe8-b8+ Kd6-c6 Qb8-c8+
Kc6-d5 Qc8-f5+ Kd5-d4 Qf5xa5 Kd4-c4) +132.53/37 4} Kf5



Then the expected output:-
Code:
59. Rh1 Qe4 60. Qg8+ Kf5

I tried sed and awk but failed to do so as I'm not at all good with them. Smilie Please help!

Many Thanks!!

Last edited by prvnrk; 07-08-2018 at 05:14 PM..
 

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
IRSEND(1)								FSF								 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.8.7pre1 May 2010 IRSEND(1)
All times are GMT -4. The time now is 08:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy