Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Including Hash / in sed command filter Post 303030623 by Xtreme on Wednesday 13th of February 2019 03:27:01 AM
Old 02-13-2019
Including Hash / in sed command filter

Hello All,

I want to print data in between two lines in a file sample.txt through more or cat command on the screen. For that I am using below sed command to give the BEGIN and END text.

Content of sample.txt

Code:
server01:~ # cat /proc/mdstat

Hello this is a text message 1
Hello this is a text message 2
Hello this is a text message 3
Hello this is a text message 4
Hello this is a text message 5

Code:
server01:~ # df -k

TESTING 1
TESTING 2
TESTING 3
TESTING 4
TESTING 5

Code:
server02:~ # df -k

Command and its output:

Code:
server01:~ # more sample.txt | sed -n -e '/server01:~ # cat/,$p' | sed -e '/server01:~ # df -k/,$d'

Hello this is a text message 1
Hello this is a text message 2
Hello this is a text message 3
Hello this is a text message 4
Hello this is a text message 5

The above method is working fine but since I may have more cat text for server01 in sample.txt so I want to include complete text 'server01:~ # cat /proc/mdstat' in the BEGIN or END in between the sed / / for exact matching. But it gives error when I put like below because the matching string itself contains Hash (/) :

Code:
server01:~ # more sample.txt | sed -n -e '/server01:~ # cat/proc/mdstat/,$p' | sed -e '/server01:~ # df -k/,$d'


Please suggest the way forward
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or other tool to manipulate data, including email addresses

I have a list of names and email addresses, like this. The <tab> markers are actually tabs. joe.blow <tab> joe.blow@wherever.com tom.t.hall <tab> tom.t.hall@wherever.com john.r.smith <tab> john.r.smith@wherever.com sally.jones <tab> sally.jones@state.or.us I want to parse the data so that... (3 Replies)
Discussion started by: manouche
3 Replies

2. Shell Programming and Scripting

How to use sed to remove html tags including text between them

How to use sed to remove html tags including text between them? Example: User <b> rolvak </b> is stupid. It does not using <b>OOP</b>! and should output: User is stupid. It does not using ! Thank you.. (2 Replies)
Discussion started by: alphagon
2 Replies

3. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

4. Shell Programming and Scripting

How to filter only comments while reading a file including line break characters.

How do I filter only comments and still keep Line breaks at the end of the line!? This is one of the common tasks we all do,, How can we do this in a right way..!? I try to ignore empty lines and commented lines using following approach. test.sh # \040 --> SPACE character octal... (17 Replies)
Discussion started by: kchinnam
17 Replies

5. Shell Programming and Scripting

sed: remove characters between and including 2 strings

I have the following line: 4/23/2010 0:00:38.000: Copying $$3MSYDDC02$I would like to use sed (or similiar) to remove everthing between and including $ that appears in the line so it ends up like this. 4/23/2010 0:00:38.000: Copying 3MSYDDC02I have been trying these but i'm really just... (5 Replies)
Discussion started by: jelloir
5 Replies

6. Shell Programming and Scripting

Filter date and time form a file using sed command

I want to filter out the date and time from this line in a file. How to do this using sed command. on Tue Apr 19 00:48:29 2011 (12 Replies)
Discussion started by: vineet.dhingra
12 Replies

7. Shell Programming and Scripting

Problem with filter data using sed command

Hi, I am using the following command(sed) to get the key/value pair from the string String="{ "test":"test message", "testmessage":"subscription is active, charge successfully} " }" status=$( echo $String | sed -e 's/^.*\("testmessage":*\).*$/\1/') echo $status i am getting this... (2 Replies)
Discussion started by: nanthagopal
2 Replies

8. Shell Programming and Scripting

sed - remove begin of line up to the third and including occurence of character

hello. How to remove all characters in a line from first character ( a $ ) until and including the third occurrence of that character ( $ ). Any help is welcome. (10 Replies)
Discussion started by: jcdole
10 Replies

9. Shell Programming and Scripting

Remove bracket including text inside with sed

Hello, I could not remove brackets with text contents myfile: Please remove the bracket with text I wish to remove: I tried: sed 's/\//' myfile It gives: Please remove the bracket with text A1 I expect: Please remove the bracket with text Many thanks Boris (2 Replies)
Discussion started by: baris35
2 Replies

10. Shell Programming and Scripting

Issue with user input including * (glob) and sed

Hello All, I have created a script that searches for different things and "sanitizes" the findings from files. Currently the user is required to put in a hostname (server.serverfarm.abc) one at a time to replace. I would like the user be able to use *.*.abc in grep and then pipe into sed to... (1 Reply)
Discussion started by: jvezinat
1 Replies
msgcc(1)							   User Commands							  msgcc(1)

NAME
msgcc - C language message catalog compiler SYNOPSIS
msgcc [-M-option] [cc-optionsoption] file... DESCRIPTION
msgcc is a C language message catalog compiler. It accepts cc style options and arguments. A msgcpp(1) .mso file is generated for each input .c file. If the -c option is not specified then a gencat(1) format .msg file is generated from the input .mso and .msg files. If -c is not specified then a .msg suffix is appended to the -o file if it doesn't already have a suf- fix. The default output is a.out.msg if -c and -o are not specified. If -M-new is not specified then messages are merged with those in the pre-existing -o file. OPTIONS
The following options are supported: cc-options Specify cc style options and arguments. -M-option Set a msgcc option. Specify option as one of the following: mkmsgs The -o file is assumed to be in mkmsgs(1) format. new Create a new -o file. preserve Messages in the -o file that are not in new .msg file arguments are preserved. The default is to either re- use the message numbers with new message text that is similar to the old or to delete the message text, leaving an unused message number. set=number Set the message set number to number. The default is 1. similar=number The message text similarity message threshold. The similarity measure between old and new message text is: 100*(2*gzip(old+new) /(gzip(old)+gzip(new))-1) where gzip(x) is the size of text x when compressed by gzip. The default threshold is $__similar__$.A threshold of 0 turns off message replacement, but unused old messages are still deleted. Use -M-preserve to preserve all old messages. verbose Trace similar message replacements on the standard error. OPERANDS
The following operands are supported: file Specifies the name of the file on which msgcc operates. EXIT STATUS
0 Successful completion. >0 An error occurred. EXAMPLES
Example 1 Using msgcc The following example uses msgcc to extract localizable strings from the file hello.c, marked using ERROR_dictionary(), writes them to the file hello.mso, and creates a gencat format xxx.msg file: example% cat hello.c #include <stdio.h> #include <stdlib.h> /* * dummy macro to avoid including * libast headers */ #define ERROR_dictionary(x) x int main(int ac, char *av[]) { puts( ERROR_dictionary("hello world") ); return( EXIT_SUCCESS ); } example% msgcc -o xxx -D__STDC__ -D__i386 hello.c example% cat hello.mso str "hello world" example% cat xxx.msg $ xxx message catalog $translation msgcc 2007-09-25 $set 1 $quote " 1 "hello world" AUTHORS
Glenn Fowler, gsf@research.att.com ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWastdev | +-----------------------------+-----------------------------+ |Interface Stability |Volatile | +-----------------------------+-----------------------------+ SEE ALSO
cpp(1), gencat(1), mkmsgs(1), msggen(1), msgcpp(1), msgcvt(1), attributes(5) SunOS 5.11 9 Oct 2007 msgcc(1)
All times are GMT -4. The time now is 08:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy