Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-16-2012
Registered User
 
Join Date: Jan 2009
Posts: 171
Thanks: 36
Thanked 1 Time in 1 Post
[Solved] Help to remove a line from a file

Hi,

I just upgraded one my server to latest version RHEL, I have many users who will do SSH from another server. I wanted to update all of the users home directory and remove the security key. For example.
/home/XYZ/.ssh/known_hosts and remove this hostsname.
Please see below and advise. Thanks.



Code:
 
#!/bin/ksh -e
XYZ='ls -1 /home'  ## need to list each of the home directory
for USERS in /$XYZ/.ssh/known_hosts ' ## each users home directory.
do
sed 's/txus03/g'   ##  remove the line txus03, replace with nothing
done

Sponsored Links
    #2  
Old 11-16-2012
in2nix4life's Avatar
Registered User
 
Join Date: Oct 2007
Location: East Coast
Posts: 308
Thanks: 0
Thanked 69 Times in 67 Posts

Code:
find /home -name 'known_hosts' -exec sed -i -e 's/txus03//g' {} \;

The Following User Says Thank You to in2nix4life For This Useful Post:
samnyc (11-16-2012)
Sponsored Links
    #3  
Old 11-16-2012
Registered User
 
Join Date: Jan 2009
Posts: 171
Thanks: 36
Thanked 1 Time in 1 Post
Quote:
Originally Posted by in2nix4life View Post
Code:
find /home -name 'known_hosts' -exec sed -i -e 's/txus03//g' {} \;

wow, you make it so simple, I was trying to do all kinds of crazy things. Thank you so much.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[Solved] remove file extension babom Shell Programming and Scripting 7 09-26-2012 05:57 AM
[Solved] Rename file name / remove part of name borobudur UNIX for Dummies Questions & Answers 2 04-24-2012 05:00 PM
[Solved] Read a .gz file line by line without using gzcat aikhaman Shell Programming and Scripting 4 10-06-2010 01:25 AM
[Solved] Problem in reading a file line by line till it reaches a white line hakermania Shell Programming and Scripting 3 08-19-2010 11:37 AM



All times are GMT -4. The time now is 09:56 AM.