Sponsored Content
Top Forums Shell Programming and Scripting remove characters from string based on occurrence of a string Post 302493827 by ghostdog74 on Thursday 3rd of February 2011 08:37:41 PM
Old 02-03-2011
Code:
$ var=dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq
$ echo ${var%%_vw_*}
dwc2_dfg_ajja_dfhhj

 

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
MB_STRRPOS(3)								 1							     MB_STRRPOS(3)

mb_strrpos - Find position of last occurrence of a string in a string

SYNOPSIS
int mb_strrpos (string $haystack, string $needle, [int $offset], [string $encoding = mb_internal_encoding()]) DESCRIPTION
Performs a multibyte safe strrpos(3) operation based on the number of characters. $needle position is counted from the beginning of $haystack. First character's position is 0. Second character position is 1. PARAMETERS
o $haystack - The string being checked, for the last occurrence of $needle o $needle - The string to find in $haystack. o $offset - May be specified to begin searching an arbitrary number of characters into the string. Negative values will stop searching at an arbitrary point prior to the end of the string. o $encoding -The $encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used. RETURN VALUES
Returns the numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns FALSE. CHANGELOG
+--------+---------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------+ | 5.2.0 | | | | | | | Added the optional parameter $offset. | | | | +--------+---------------------------------------+ NOTES
Note The $encoding parameter was moved from the third position to the fourth in PHP 5.2.0. For backward compatibility, $encoding can be specified as the third parameter, but doing so is deprecated and will be removed in the future. SEE ALSO
mb_strpos(3), mb_internal_encoding(3), strrpos(3). PHP Documentation Group MB_STRRPOS(3)
All times are GMT -4. The time now is 09:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy