Sponsored Content
Top Forums Shell Programming and Scripting remove characters from string based on occurrence of a string Post 302493773 by victor369 on Thursday 3rd of February 2011 05:03:18 PM
Old 02-03-2011
remove characters from string based on occurrence of a string

Hello Folks..

I need your help ..

here the example of my problem..i know its easy..i don't all the commands in unix to do this especiallly sed...here my string..

dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq

desired output is..

dwc2_dfg_ajja_dfhhj

it's a simple task with tail command, but my string size varies..only constant thing is ocuurance of this string "_vw_"

I greatly appretiate your help..

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove special characters from string

Hi there, I'd like to write a script that removes any set of character from any string. The first argument would be the string, the second argument would be the characters to remove. For example: $ myscript "My name's Santiago. What's yours?" "atu" My nme's Snigo. Wh's yors? I wrote the... (11 Replies)
Discussion started by: chebarbudo
11 Replies

2. Shell Programming and Scripting

how to remove characters from a string

Hi. for the following line: Var1=${Array} now Array has text as "{hello there}" how do I remove the {} brackets before assigning the string to Var1? Thanks. (3 Replies)
Discussion started by: shadow_boi
3 Replies

3. Shell Programming and Scripting

remove last 4 characters from a string

I'm tring to remove the last 4 characters from strings in a file i.e. cat /tmp/test iwishicouldremovethis icouldremovethos so i would end up with the last 4 characters from each of the above i.e. this thos I thought of using cut -c ... but I'm not sure how many characters will... (7 Replies)
Discussion started by: josslate
7 Replies

4. Shell Programming and Scripting

Remove characters from string

Hi I am new in shell scripting and i want to manipulate a string. I have a string tha looks like: /home/nteath/file.txt I want to remove everything until the last "/" , to keep only the filename. e.g. /home/nteath/file.txt output: file.txt Thanks (2 Replies)
Discussion started by: nteath
2 Replies

5. Shell Programming and Scripting

Remove string between two special characters

Hi All, I have a variable like AVAIL="\ BACK:bkpstg:testdb3.iad.expertcity.com:backtest|\ #AUTH:authstg:testdb3.iad.expertcity.com:authiapd|\ TEST:authstg:testdb3.iad.expertcity.com:authiapd|\ " What I want to do here is that If a find # before any entry, remove the entire string... (5 Replies)
Discussion started by: engineermayur
5 Replies

6. UNIX for Dummies Questions & Answers

counting occurrence of characters in a string

Hello, I have a string like this 0:1:2:0:2:2:4:0:0:0:-200:500...... what i want is to break down how many different characters are there and their count. For example for above string it should display 0 - 5 times 1 - 1 times 2 - 3 times 4 - 1 times . . . I am stuck in writing... (8 Replies)
Discussion started by: exit86
8 Replies

7. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

How to remove some special characters in a string?

Hi, I have string like this ="Lookup Procedure" But i want the output like this Lookup Procedure =," should be removed. Please suggest me the solution. Regards, Madhuri (2 Replies)
Discussion started by: srimadhuri
2 Replies

9. Shell Programming and Scripting

Remove last occurrence of character (_) and rest of the string in UNIX (sed)

Hi I need help on this ..!! Input : xx_abc_regA xx_def_regB xx_qwe_regC Now i required the output as the below abc def qwe Need to remove last occurrence of character (_) and rest of the string in Unix (sed). Thanks in Advance ..!!! -Nallachand (3 Replies)
Discussion started by: Nallachand
3 Replies

10. UNIX for Dummies Questions & Answers

Count occurrence of string (based on type) in a column using awk

Hello, I have a table that looks like what is shown below: AA BB CC XY PQ RS AA BB CC XY RS I would like the total counts depending on the set they belong to: if search pattern is in {AA, BB, CC} --> count them as Type1 | wc -l (3 Replies)
Discussion started by: Gussifinknottle
3 Replies
CONSTANT(3)								 1							       CONSTANT(3)

constant - Returns the value of a constant

SYNOPSIS
mixed constant (string $name) DESCRIPTION
Return the value of the constant indicated by $name. constant(3) is useful if you need to retrieve the value of a constant, but do not know its name. I.e. it is stored in a variable or returned by a function. This function works also with class constants. PARAMETERS
o $name - The constant name. RETURN VALUES
Returns the value of the constant, or NULL if the constant is not defined. ERRORS
/EXCEPTIONS An E_WARNING level error is generated if the constant is not defined. EXAMPLES
Example #1 constant(3) example <?php define("MAXSIZE", 100); echo MAXSIZE; echo constant("MAXSIZE"); // same thing as the previous line interface bar { const test = 'foobar!'; } class foo { const test = 'foobar!'; } $const = 'test'; var_dump(constant('bar::'. $const)); // string(7) "foobar!" var_dump(constant('foo::'. $const)); // string(7) "foobar!" ?> SEE ALSO
define(3), defined(3), The section on Constants. PHP Documentation Group CONSTANT(3)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy