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
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 07:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy