Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

problem with shell script syntax

Posted on 2006-05-25
1
Medium Priority
?
266 Views
Last Modified: 2010-04-21
1)
I'd like to write a shell script to scan and file and look for a string and if the string exist to echo it on the console
by example: i like to look for 172.16.8.222 in /root/myips if found echo it to the screen.

2)
i'D also like to write a shell script to write a string to a file.

by example: i d like to write 172.16.8.222 to /root/myips, i do not my data to be overwritten

3) how can i remove a string from a file
by example: i'd like to remove 172.16.8.222 from /root/myips

please help, ty
0
Comment
Question by:247RealMedia
1 Comment
 
LVL 85

Accepted Solution

by:
ozo earned 1500 total points
ID: 16763017
fgrep  172.16.8.222  /root/myips
echo 172.16.8.222 >> /root/myip
perl -i.bak -pe 's/\Q172.16.8.222\E//g'  /root/myip
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question