Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Append a particular string after occurrence of particular string. Post 303039591 by Neo on Thursday 10th of October 2019 01:57:59 AM
Old 10-10-2019
And how do you intend to solve your issue to append some text in your file?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search a string and append text after the string

Hi, I have a file like this... <o t="Batch" id="8410" p="/" g="32"> <a n="name"> <v s="DBBA1MM"/> </a> <a n="owner"> <v r="/Administrator"/> </a> <a n="rights"> <v s="95"/> </a> <a n="debugLevel"> <v s="3"/> </a> <a n="avsStoreLoc"> <v... (8 Replies)
Discussion started by: kesu2k
8 Replies

2. Shell Programming and Scripting

Displaying only First Occurrence of a String

Hi, My requirement is that I should search for a particular string and display the string only once if there is more occurrence of the same string in a file. e.g In the given below log file,the string AMQ5037 comes twice.I want to search for this string and display it only once.grep will... (5 Replies)
Discussion started by: charudpss
5 Replies

3. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: victor369
5 Replies

4. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

5. Shell Programming and Scripting

Append a searched string with another string using sed

Hi, I need to replace and append a string in a text if grep is true. For eg: grep ABC test.txt | grep -v '\.$' | awk {'print $4'} | sed "s/ ? How do I replace all instances of "print $4" using sed with another sring? Eg of the string returned will be, lx123 web222 xyz Want to... (8 Replies)
Discussion started by: vchee
8 Replies

6. Shell Programming and Scripting

How to append a string by comparing another string?

Hi , I have one file like BUD,BDL BUDCAR BUD,BDL BUDLAMP ABC,CDF,KLT ABISKAR ABC,CDF,KLT CORNEL ABC,CDF,KLT KANNAD JKL,HNM,KTY,KJY JAGAN JKL,HNM,KTY,KJY HOUSE JKL,HNM,KTY,KJY KATAK JKL,HNM,KTY,KJY KOLKA The o/p should be like BUD,BDL BUDCAR,BUDLAMP ABC,CDF,KLT... (4 Replies)
Discussion started by: jagdishrout
4 Replies

7. Shell Programming and Scripting

How to append string checking other same string?

Hi , I have a file likeA-0044150|ABC/Frito/ A-0044150|GFHU A-0150075|Bud Racing A-0187811|Bud Light A-0187811|RW&B signmaking I Want the o/p likeA-0044150|ABC/Frito/,GFHU A-0150075|Bud Racing A-0187811|Bud Light,RW&B signmaking (2 Replies)
Discussion started by: jagdishrout
2 Replies

8. Shell Programming and Scripting

Find a string occurrence if twice in a line

Hello All, I want to check if a delimiter is existing twice in a line of a text file. Suppose flat file is like this 234 | 123 123 | 345 456 | 563 | 234 | 548 So the the 3rd line has two delimiters, How can we find the lines in such a file having more then one delimiters I tried... (5 Replies)
Discussion started by: nnani
5 Replies

9. Shell Programming and Scripting

Find string in file and append new string after

Hi All, I'm trying to insert a string into a file at a specific location. I'd like to add a string after the parent::__construct(); in my file. <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function... (6 Replies)
Discussion started by: jjkilpatrick
6 Replies

10. Shell Programming and Scripting

[Solved] Last occurrence of a string

I apologize if it was asked before but I couldn't find something related. I want to replace 2 strings in a file e.g pwddb=Lar1wod (need to replace string after =) pwdapp=Wde2xe (need to replace string after =) AND in same file want to find last occurrence of a string (SR2-134561),... (2 Replies)
Discussion started by: J_ang
2 Replies
MB_STRRICHR(3)								 1							    MB_STRRICHR(3)

mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive

SYNOPSIS
string mb_strrichr (string $haystack, string $needle, [bool $part = false], [string $encoding = mb_internal_encoding()]) DESCRIPTION
mb_strrichr(3) finds the last occurrence of $needle in $haystack and returns the portion of $haystack. Unlike mb_strrchr(3), mb_strrichr(3) is case-insensitive. If $needle is not found, it returns FALSE. PARAMETERS
o $haystack - The string from which to get the last occurrence of $needle o $needle - The string to find in $haystack o $part - Determines which portion of $haystack this function returns. If set to TRUE, it returns all of $haystack from the beginning to the last occurrence of $needle. If set to FALSE, it returns all of $haystack from the last occurrence of $needle to the end, o $encoding - Character encoding name to use. If it is omitted, internal character encoding is used. RETURN VALUES
Returns the portion of $haystack. or FALSE if $needle is not found. SEE ALSO
mb_stristr(3), mb_strrchr(3). PHP Documentation Group MB_STRRICHR(3)
All times are GMT -4. The time now is 03:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy