Sponsored Content
Top Forums Shell Programming and Scripting Sed question (Removing a line of text) Post 302269077 by masterscout1977 on Tuesday 16th of December 2008 08:33:25 PM
Old 12-16-2008
Question Sed question (Removing a line of text)

I am working with bash on HP-UX server at school.
As practice for scripting, I am trying to make a pretend server admin script that adds a user to the system, deletes a user from the system, and lists all users of the pretend system. I have accomplished this with a select loop. Adding users, and listing users I have figured out, but my problem is deleting users from the passwd file.

I am trying to use sed to display the passwd file without the line containing the unique user id then redirect to a temporary file. Then I take the temporary file and rename it as the passwd file, effectively removing the user from the passwd file. The problem I am running into is the proper way to get sed to show all lines except for the one I want to remove, could anyone help me?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl question - removing line from input file

In perl I want to do remove the top line of my input file then process the next line. I want to do something like head -1 inputfile > temp grep -v temp inputfile > newinputfile cp newinputfile inputfle is this possible in perl? (3 Replies)
Discussion started by: reggiej
3 Replies

2. UNIX for Dummies Questions & Answers

removing parts of a line with SED

hi, i'm trying to erase all the characters after, and including, the first test test Output: test1 test2 test3 this is what I tried, but didn't work sed "s/*//" file > testfilename any suggestions? thanks, gammmaman (2 Replies)
Discussion started by: gammaman
2 Replies

3. Shell Programming and Scripting

Removing a particular line from a text file

Hi, I have a file called inp.txt the contents of the file are as follows MANI123|23|41 MANI123|96|23 I want to reove the first line of this file. How can I do it. Thanks in advance (5 Replies)
Discussion started by: sendhilmani123
5 Replies

4. Shell Programming and Scripting

Removing text from a line in a file

Hi All, I would like to know how to remove text from a line in a file. eg to The 4 sets of numbers are not static ie they change on each line in each different file so if anyone can help that would be great. Jeremy (10 Replies)
Discussion started by: outthere_3
10 Replies

5. Shell Programming and Scripting

removing a line containing a pattern in sed

i need to use sed to remove an entire line containing a pattern stored in a variable say $var1 this var1 will be a URL and will therefore contain slashes any help would be greatly appreciated (1 Reply)
Discussion started by: Fire_Storm
1 Replies

6. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

7. Shell Programming and Scripting

sed removing until end of line

All: Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line If I have the following input ... (5 Replies)
Discussion started by: BeefStu
5 Replies

8. Shell Programming and Scripting

Help with removing line from text

Hey everyone, I kinda new to shell programming and learning bits and pieces of stuff from tutorials. I got this problem, where I asked my user to enter a string, which will delete a specific line in the string, which I'm unable to do it. Text file(BookDB.txt) as shown: Three Little... (4 Replies)
Discussion started by: aLHaNz
4 Replies

9. Shell Programming and Scripting

awk :quick question removing empty line.

How to write in awk to remove lines starting with "#" and then process the file: This is not working: cat file|awk '{if ($0 ~ /^#/) $0="";print NF>0}' When I just give cat file|awk '{if ($0 ~ /^#/) $0="";print }' it prints the blank lines . I don't wnat the blank lines along with the... (15 Replies)
Discussion started by: rveri
15 Replies

10. Answers to Frequently Asked Questions

How to prevent sed command removing whole line?

hello, I'm using sed command to extract the text between 2 special characters which are /* and */ I used following command to do this. sed -n '/\/\*/,/\*\//p' file.txt But if the file.txt contains a line something like this, a=5; /* this is a comment */ the above command... (3 Replies)
Discussion started by: beginner_99
3 Replies
ADDING_USER(8)						    BSD System Manager's Manual 					    ADDING_USER(8)

NAME
adding_user -- procedure for adding new users DESCRIPTION
A new user must choose a login name, which must not already appear in /etc/passwd or /etc/mail/aliases. It must also not begin with the hyphen '-' character. It is strongly recommended that it be all lower-case, and not contain the dot '.' character, as that tends to confuse mailers. An account can be added by editing a line into the passwd file; this must be done with the password file locked e.g. by using chpass(1) or vipw(8). A new user is given a group and user id. Login and user id's should be unique across the system, and often across a group of systems, since they are used to control file access. Typically, users working on similar projects will be put in the same groups. At the University of California, Berkeley, we have groups for system staff, faculty, graduate students, and special groups for large projects. A skeletal account for a new user ``ernie'' might look like: ernie::25:30::0:0:Ernie Kovacs,508 Evans Hall,x7925, 642-8202:/a/users/ernie:/bin/csh For a description of each of these fields, see passwd(5). It is useful to give new users some help in getting started, supplying them with a few skeletal files such as .profile if they use /bin/sh, or .cshrc and .login if they use /bin/csh. The directory /usr/share/skel contains skeletal definitions of such files. New users should be given copies of these files which, for instance, use tset(1) automatically at each login. FILES
/etc/master.passwd user database /usr/share/skel skeletal login directory SEE ALSO
chpass(1), finger(1), passwd(1), aliases(5), passwd(5), adduser(8), pwd_mkdb(8), vipw(8) BSD
January 30, 2009 BSD
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy