I have created a script that searches for different things and "sanitizes" the findings from files. Currently the user is required to put in a hostname (server.serverfarm.abc) one at a time to replace. I would like the user be able to use *.*.abc in grep and then pipe into sed to make changes.
I am currently stuck on having sed actually replace grep findings that include *.*.abc
I have tried different shopt options with no success. I believe it might be how i am writing the string (escaping characters etc). If someone could take a look at this that would be great!
I can provide more of the script if needed. Grep finds but when piped into sed it actually doesn;t do anything.
The variables are put in by the user. They are asked a hostname and input. They are asked what will replace ($change) the $hostname. Directory is also input from the user.
Any suggestions with using sed before i move on to a different tool? thanks!
Moderator's Comments:
edit by bakunin: Please use CODE-tags for code, data and terminal output as required by the rules. Thank you.
--- Post updated at 10:46 PM ---
Hello All,
The following seems to work:
I am plugging this into the much larger script and will test from there. Once again, with many ways to skin a cat, I would be interested how i could improve upon this, thanks!
--- Post updated at 10:47 PM ---
Correction:
Moderator's Comments:
edit by bakunin: Please use CODE-tags for code, data and terminal output as required by the rules. Thank you.
He guys.
Basically I want to make a script that can add, delete and view stuff in a external file called config.txt. I can open it up in Joe but im not sure how to read in the user input or using commands automatically in joe to edit, save then quit.
Problem area below:
1) echo "Add... (1 Reply)
How to use sed to remove html tags including text between them?
Example: User <b> rolvak </b> is stupid. It does not using <b>OOP</b>!
and should output: User is stupid. It does not using !
Thank you.. (2 Replies)
Dear all
Ihave written a script in Hpux9.0, the ecript is working fine if I run it from root command prompt
But when I am running it thru /etc/profile or /user/.profile and login as a normal user, the owner of the process running the script is the normal user & hence cant run a root privileaged... (7 Replies)
I have the following line:
4/23/2010 0:00:38.000: Copying $$3MSYDDC02$I would like to use sed (or similiar) to remove everthing between and including $ that appears in the line so it ends up like this.
4/23/2010 0:00:38.000: Copying 3MSYDDC02I have been trying these but i'm really just... (5 Replies)
Hi
I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this
Enter the line to... (1 Reply)
Hi,
echo "Enter file name of input file list along with absolute path : "
read inputFileList
if
then
for string in `cat inputFileList`
do
echo $string
done
else
echo " file does not exist"
fi
From the above code, if the user enters a invalid file... (1 Reply)
Hi
I want to delete a line from a txt file for which the line number is user input. Say when user selects 19, the 19th line would be deleted from the file. Can anyone please provide me with a sed one liner for the same... I tried sed -i. The interaction would be like this
Enter the line... (4 Replies)
Hello,
I could not remove brackets with text contents
myfile:
Please remove the bracket with text
I wish to remove:
I tried:
sed 's/\//' myfile
It gives:
Please remove the bracket with text A1
I expect:
Please remove the bracket with text
Many thanks
Boris (2 Replies)
Hello All,
I want to print data in between two lines in a file sample.txt through more or cat command on the screen. For that I am using below sed command to give the BEGIN and END text.
Content of sample.txt
server01:~ # cat /proc/mdstat
Hello this is a text message 1
Hello this is a... (5 Replies)