Software :: Replace A Text String In A File With A Random String - With Sed ?

Sep 2, 2010

I have a line in a text file that has 40 random characters within a tag and i want to change the characters to a new set of 40 random characters (alphanumeric a-z 0-9 etc)

The line in the text file looks like this:

Quote:

How would i go about doing that?

Also second question same as the above but how would i remove them instead of replacing them?

View 14 Replies


ADVERTISEMENT

Fedora :: Replace A String By A String In Text File?

Apr 26, 2011

If I have a word in a text file and I need to replace it by another word (for example, i need to replace abc by fff) so what is the command I can type it?

I am using vi editor.

View 3 Replies View Related

General :: Replace Nth Occurence Of String In Each Line Of A Text File?

May 20, 2010

I have large text files with space delimited strings (2-5). The strings can contain "'" or "-". I'd like to replace say the second space with a pipe. What's the best way to go?
Using sed I was thinking of this:

sed -r 's/(^[a-z'-]+ [a-z'-]+) /1|/' filename.txt

View 2 Replies View Related

Programming :: Text File Replace Occurrences Of Three Character String ZZZ With Quotation Mark

Mar 30, 2010

I want to use SED to do the following: In a text file replace any occurrences of the three character string ZZZ with a quotation mark "and. replace all occurrences of a comma with a semi-colon. It is the S/ / / command which is stumping me on the first issue...inparticular how to get the replace string to be quote.

View 9 Replies View Related

Programming :: Using Sed Replace Line Containing Particular String By A Single String?

Oct 16, 2010

I have a set of lines as ahown below:

Leon went to school
Leon came back from school..
Leon had dinner...

I have to replace the line containing "dinner" by a single string LUNCH...

View 2 Replies View Related

General :: Replace String With Empty String Of Dir Path ?

Apr 2, 2011

I want to replace a string of directory path in a string to empty:

Code:

But this doesnt seem to give me the desired thing:

Code:

This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.

View 3 Replies View Related

Software :: Best Software To Replace A String In A Big Text File?

May 22, 2011

I have a big text file (350mb) and i need to replace some strings in it.

The VIM is too slow. Also I don't need to open file and view its contents. I just need to give the command to replace it for faster processing.

Which software would be the best for this purpose?

View 7 Replies View Related

Ubuntu :: Bash Script To Delete/replace A Specific String Of Text?

Jun 17, 2010

What i want to do is pretty simple.I want to uncomment every line that begins with "deb" (except for deb cdrom) in /etc/apt/sources.list.I know how to do this through system > administration > software sources.I know I can gksu gedit /etc/apt/sources.list.I'd rather not do it that way.I'd rather have a script do it. It's less work, less typing, less clicking, and would work the same on every ubuntu version.

View 8 Replies View Related

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related

General :: String Replace In Filenames - Files Already Contain The String "Soundtrack"

Jun 11, 2011

Moving right along, I have a folder of MP3 files containing various Movie sound tracks and scores. I'm using Audio Tag Tool to tag all the files at once with an "Artist" of "Soundtrack", and to inherit the "Title" tag from the file name. After that, I will rename all the files (Using Audio Tag Tool -- awesome program, btw) with the format "<Artist> - <Title>.mp3"

The problem, is many of my files already contain the string "Soundtrack", which would be redundant. I happen to be a perfectionist, so I'm unable to ignore it and move on. Hence my question to you fine folk: I want to delete all instances of "soundtrack" (-i case irrelevant) in the filenames before I go through the above steps. But, its not quite that simple. This is a sample of some of the file names:

[Code]....

View 3 Replies View Related

Programming :: Replace A String Within A File ?

Feb 28, 2009

I've found some scripts that replaces a string in a file but it's not quite working for me.

And I'm trying to replace a tag in an xml file that looks like this

So I ran a command line like this perl -w -i -p -e "s/xmlns="'http://mydomain.org/replacethese.xsd'">/>/g" testfile.xml

And I get a error output

Search pattern not terminated at -e line 1.

Found the script from this blog [url]

View 7 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

Programming :: Replace 2nd Occurrence Of A String In A File - Sed Or Awk?

Apr 5, 2010

I know how to replace a particular instance (say 3rd one) of a word in a line using sed based on the sed one-liners. However I would like to replace a particular instance of a word in the entire file.

For example, here is a file:

Code:
John
Betty
Jack
Ron
Jack
Paul

So now I would like to replace the second instance of Jack (in red color) with "Rob" (for example). Not quite sure how to do that? I tried couple of things from here but they did not work.

View 10 Replies View Related

Programming :: Replace String In File Using Perl Or Sed

Jun 30, 2011

I have question about replacing a string in a file.

How can I replace the printerb's 10.1.1.1 to something else(10.1.1.2, for example) without replace printera's 10.1.1.1 accidentally?

I have tried perl -e -pi "s/10.1.1.1/10.1.1.2/g" /etc/hosts. but, perl replace both 10.1.1.1 to 10.1.1.2.

View 13 Replies View Related

General :: Using Sed To Replace String With Special Characters In XML File?

Apr 29, 2011

I am having difficulty getting sed to replace a string of text in an XML file, despite the fact that I have no trouble using grep to find that same string. Since the new string and old string to be replaced contain a lot of special characters, I thought it best to store them in variables as opposed to using a slew of backslashes:

OLD_STRING='<property name="webServiceHost">${jboss.bind.address}</property>'
NEW_STRING='<!--<property name="webServiceHost">${jboss.bind.address}</property>-->'

[Code]....

View 2 Replies View Related

General :: Replace A String In Multiple File & Sub Directories?

Aug 31, 2010

Need to replace the following string :

By

In multiple .exp files and in sub directories.

View 5 Replies View Related

General :: Replace A String In A File Using A Script With Path Containig /

Feb 26, 2010

I need to replace a string in a file(startup.sh) using a script(parser.sh). After running parser.sh startup.sh should be filled with nfs path like /home/vimal etc but im getting error since path contains /. how to remove this.

View 3 Replies View Related

Programming :: Perl Find File And Then Replace String In File

Jul 28, 2009

I have script that I'm working on that updates a username in all the files that are called blah.inc for my framework. since i host a bunch of these web apps i need to do it to all of them. so I need to figure out how to update these files automagically with out me watching it to call vim every time. heres what I have so far

Code:

This finds the files but now i need to figure out how to do s/bob/fred/g on those files.

View 5 Replies View Related

Ubuntu :: Put The String Sign Into File / String / Message (rsa)

Mar 7, 2011

I have a String that I would like to sign using a given RSA Private key. I thought this would be relatively easy but I have not been able to find out how to do it, unless I'm looking to far into a simple problem. Do i have to put the string into a file, and sign the file, or can i just sign the string/message?

View 7 Replies View Related

Programming :: Find And Replace A String In A File Using Perl Command From Bash Script?

Feb 14, 2011

I wanted to find and replace a string from a perl file. I have written a script in bash which runs the following command.

perl -pi -e "s/$findstring/$replacestring/" testfile
where as $findstring = print F_WC_TMP"$line
";
and $replaceString = $line = join ' ', split ' ', $line; print F_WC_TMP"$line
";

But when I am running the above command, i think it is replacing the $findstring with the above mentioned string and hence it contains a $line, it is looking for the variable $line and not finding the exact string. I am confused about how to search for a string that contains $ in it and replace it with another $string.

View 5 Replies View Related

Server :: Remove String In Text File?

Jun 5, 2009

I have a text file which include code...

I mean, this string should be removed from each line and save in another file.

View 9 Replies View Related

General :: Get The Shortest String In A Text File With Shell?

Apr 29, 2010

Assume I have a text file as belowabcdaaaaaaagfgkhahahahahahhahhgfThen gf would be returned

View 4 Replies View Related

General :: Find Text After String Search In File

Aug 2, 2011

I have a file called Regions.ini that looks like this:

Code:
[Granite]
RegionUUID = 54ab7cd2-0e70-49b7-8020-8dbeb84c08d0
Location = 9991,10007
InternalAddress = 0.0.0.0
InternalPort = 9001
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9

[Syenite]
RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f
Location = 9992,10007
InternalAddress = 0.0.0.0
InternalPort = 9000
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9
What I need to do is find out what the IP address is after "ExternalHostName ="

After that I will need to compare that IP to whatismyip and if it's different then replace it but that is easy to do with sed. I just can't figure this simple hurdle out.

View 12 Replies View Related

Programming :: Find String In Text File And Add Something To That Line

May 26, 2011

I want to know how can I add something to a specific line.. the output would be something like:
abc
def 123
ghi

Search for string "def" and add something to that line.

View 1 Replies View Related

Programming :: String Format - Create A Text File ?

Feb 3, 2010

I am using C. I have a fuction that returns a string

Code:

I need to format this string so that I can create a text file like so:

So I'm trying:

Code:

But I get errors like:

View 2 Replies View Related

Programming :: String Search In Text File Using Visual C++

Jan 25, 2010

im tryin to make a tool in visual C++ which will take an input string through a text box,then it will compare tht string with a text file containing data and display the matched results in list box.

View 2 Replies View Related

Software :: Check The Contents Of A Text File For A Specific String And Remove It From The File From The Command Prompt?

Oct 14, 2010

I want to be able to check the contents of a text file for a specific string and remove it from the file from the command prompt. I would basically be searching through a number of files and if a specific string is found I would like it removed automatically. pretty much a find and replace, were the replace is nothing. any one got any ideas on how you would do this. I already have the search part sorted just need to be able to remove the string I don't want from the multiple files.

View 4 Replies View Related

Debian Programming :: Script To Execute String From Text File

Sep 24, 2014

I am having trouble writing a script that monitors a text file. When the file contains number 1 (or any other string that is not a command) it does nothing, but when it is something different from 1, it executes that command.

So, there are 2 files: monitor.mon - this is the file that will be checked constanlty; and test.sh - the script that does the job. The monitor.mon file will have its content modified by php. This means a web page will have a form where I input commands and writes does commands in the file. Test.sh will watch when the file's content changes from character 1 to a command, execute that command and write back a 1 so it will not execute it more times.

I tried combining while and if but with no success. Tried reading the file with cat and grep -e but it doesn't seem to recognize when content changes.

View 4 Replies View Related

Programming :: Find String In Text File (bash Script)

Apr 17, 2011

write such script (bash script). I have some text file with name filename.txt I must check if this file contains string "test-string-first", I must cut from this file string which follows string "keyword-string:" and till first white-space and save it to some variable.

For example. File: PHP Code: PHP Code:
Start 15022011 Eng 12-3-42
SN1232324422 11 test-string-first
SN322211 securities
HH keyword-string:123456321-net mark (11-22) 

[Code].....

View 1 Replies View Related

General :: Use The Diff Command To Get The Difference Between A String Of Text And The Contents Of A File?

Mar 31, 2010

I am not especially cli adept so could someone tell me the best way to use the diff command to get the difference between a string of text and the contents of a file instead of between the contents of two files?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved