I am writing shell script for executing oracle procedure. Shell script need to take 3 parameters from one data file rest of the parameters need to pass in command line it self. Total 7 parameters are need to pass for shell script.1st,3rd,5th parameters need to take from dat file and rest of 4 parameters from command line.
Below is one oracle procedure: EXEC CIM_MGMT_INSTALL.addFlow('$1','1.0','$1','Settings','$2','ECCD2',NULL,1); $1is 1st and 3rd both places need to pass same parameter.$1,$2 need to take from data file as earlier says.
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?
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 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.
I am learning Linux and I am documenting procedures for troubleshooting for any disk related issues and I would like to know the procedure to replace a Failed hard drive running Redhat 5.1 running LVM2.
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
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:
I can construct a RE to match <start-marker>.*<end-marker>, but is there a utility that would return *just* the <good stuff> I'm interested in? I realise that the alternative is something along the lines of:
Code: cat <input-file> | awk -F'start-marker' 'print ${2}' | awk -F'end-marker' 'print ${1}' but it would be better if I could do it all in one go.
I'd like a sed command to replace all decimal values greater than 0.5 with nothing in a tab delimited text file.
EX:
There would be one tab before 0.301 and two tabs after it. This way when you paste the text into an excel spreadsheet, there are empty cells where you deleted values.
I thought the sed command would be something like:
But this will delete everything.
What I need is something that will start deleting when it sees 0.[5-9] and stop when it reaches a tab. I know you can use [^character]+ to do this, but it doesn't seem to work with a TAB as the character.
Another idea I had would be to have sed replace from 0.[5-9] to 0. and replace with a tab + 0. But I also cant get [^0.]+ to work as it only works with single characters.
Something very handy to do in a Linux shell, is manipulating files and strings - essentially parsing data. Write a utility which will scan in a text file and search and replace strings. We also want to keep track of how many strings we've replaced.
I know that my command would look like this: <utility name> <filename> <stringToSearchFor> <stringToReplaceWith> Code: #!/bin/bash
How to replace a line containing some word by only another word...
Ex: The sed program is the Linux stream editor utility The pattern is a regular expression that you wish to match and replacement is the new string to ..
replace the line containing 'program' by only word LINUX
I am trying to replace a string (url) in 100s of files located in different directories. I found the sed command but cannoy get it to work. First I locate the files that have the string in them:
Code: grep -ilr 'url' * this works correctly and displayed the location of the files that have the string: Code: 1/index.php 2/index.php
Now I need to replace the string so I combined it with sed:
I am trying to replace the first number in a string at the end of the line with the word that matches that number. for example i want to replace 546215 to be five-46215. The command that I have tried is
I am trying to replacee all digits with a symbol (say, big U here) in a string by
[code]...
The result become 'UsUoUmUeUtUhUiUnUgU' instead of 'somethingUUU' as expected. Looks like my string contains some 'hidden digits' in between the letters. Does anyone have an idea about that?
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.
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:
After hours (literally) of searching the web and reading man pages, I think I've come up with the following:Code:find . -exec grep 'path/to/file' -print | xargs -0 -I new_path mv {this is where I get confused}So my code above is incomplete, obviously. In order to finish replacing the string, I need to mv the new file into the old file's spot. How do I do this, by incorporating it into my line of code?
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:
I want to know the Perl command to replace a string by pointing the line number. I know how to replace a string without pointing a line number but I am in need to replace only the two matching string in a file
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.
But the problem is that in this case i just wanted to append "/home/dest" for which I could easily escape "/" with just two "", but I wonder if i have a long path like "/a/b/c/d/e/f/g/h/i/j" I will have to escape so many /. Is there any other way by which I can avoid escaping forward slash.
I tried following:
But receiving follo error
Bareword found where operator expected at -e line 1, near "s/destination-path=/'destination-path=/home" syntax error at -e line 1, near "s/destination-path=/'destination-path=/home" Bad name after dest' at -e line 1. tried with enclosing in double quotes as well but in vain