Sponsored Content
Top Forums Shell Programming and Scripting Delete specific lines from a file Post 302305345 by vgersh99 on Wednesday 8th of April 2009 03:27:18 PM
Old 04-08-2009
assuming users to be deleted are in a file 'users2del.txt':
Code:
orcladmin
PUBLIC
portal
portal_admin
uddi_publisher
uddi_publisher1
ias_admin
uddi_replicator

Code:
nawk -F'=|,' 'FNR==NR {f1[$0];next} !($2 in f1)' users2del.txt all_users.ldif

 

10 More Discussions You Might Find Interesting

1. Programming

Delete specific lines in a text file

Hi, experts, I would like to create a function that can calculate the total number of lines in a saved text file and delete specific lines in that particular file (I only want the last few lines). Hav anybody have the experience and giv me a hand in this? (9 Replies)
Discussion started by: dniz
9 Replies

2. UNIX for Advanced & Expert Users

How to delete specific lines at the same time

Dear All I have a pattern which look like this: 2 20080312_10:55:35.800 Spain-Telefonica ISC 9 IAM 927535957 34670505334 f 275 COT b 700 ACM b 6577 CPG b 10726 ANM b 202195 REL f 202307 RLC :COMMA: NCI=15,FCI=2101,CPC=0A,TMR=00,USI,OFI=00: :COMMB: BCI=0214,OBI=01,ACT: :RELCAUSE:10: This... (1 Reply)
Discussion started by: zanetti321
1 Replies

3. Shell Programming and Scripting

Delete lines prior to a specific date in a log file.

Hi all. I have a database log file in which log data get appended to it daily. I want to do a automatic maintainence of this log by going through the log and deleting lines belonging to a certain date. How should i do it? Please help. Thanks. Example. To delete all lines prior to Jun... (4 Replies)
Discussion started by: ahSher
4 Replies

4. Shell Programming and Scripting

How to delete all lines before a specific word?

Let's say we have a file containing: alllllsadfsdasdf qwdDDDaassss ccxxcxc#2222 dssSSSSddDDDD D1Sqn2NYOHgTI Hello Alex ssS@3 Ok, and let's say we want to delete all words from D1Sqn2NYOHgTI and back, this means to delete the words (and the lines of them) : alllllsadfsdasdf... (2 Replies)
Discussion started by: hakermania
2 Replies

5. Shell Programming and Scripting

Delete all lines after a specific line ?

Hello. My file is like this: a b c d e f g h i I want to delete all lines after the 3rd line, means after the "c". Is there any way to do this? The lines differ between them and the lines I want to delete does not have a specific word, or the lines I want to keep (a,b,c) does not have a... (4 Replies)
Discussion started by: hakermania
4 Replies

6. Shell Programming and Scripting

A way to delete specific lines

Hi all, I hope an expert tells me that there is a way to get ride of the certain lines in my files which have no specific string on them but fixed length. It's the original pattern:... (9 Replies)
Discussion started by: GoldenFire
9 Replies

7. Shell Programming and Scripting

how to delete lines from a file which starts with a specific pattern

I need to delete those lines from a file, which starts with 45. How to do it? (3 Replies)
Discussion started by: mady135
3 Replies

8. UNIX for Dummies Questions & Answers

How to delete specific lines (2n+3 line, n=0,1,2...296) in a file?

Dear everyone, I have a file with 900 lines (there is only numbers in one line, no string), I only need the lines 2+3n (n=0,1...296), i.e line 2, 5, 8, 11...888. I tried google but only the results such as how to delete all the odd lines or all the even lines with 'awk' command. Thanks in... (4 Replies)
Discussion started by: phamnu
4 Replies

9. Shell Programming and Scripting

Delete specific lines from files based on another file

I have some text files in a folder named ff as follows. I need to delete the lines (in-place editing)in these files based on another file aa.txt. 32bm.txt: 249 253 A P - 0 0 8 0, 0.0 6,-1.4 0, 0.0 2,-0.4 -0.287 25.6-102.0 -74.4 161.1 37.1 13.3 10.9 250... (2 Replies)
Discussion started by: aden
2 Replies

10. Shell Programming and Scripting

Delete lines above and below specific line of text

I'm trying to remove a specific number of lines, above and below a specific line of text, highlighted in red: <STMTTRN> <TRNTYPE>CREDIT <DTPOSTED>20151205000001 <TRNAMT>10 <FITID>667800001 <CHECKNUM>667800001 <MEMO>BALANCE </STMTTRN> <STMTTRN> <TRNTYPE>DEBIT <DTPOSTED>20151207000001... (8 Replies)
Discussion started by: bomsom
8 Replies
ruptime(1c)															       ruptime(1c)

Name
       ruptime - show host status of local machines

Syntax
       ruptime [ options ] [ machinename ]

Description
       The  command  gives  a  status  line  like  for each machine on the local network.  If a machinename is given, the status of only the named
       machine is given.  These status lines are formed from packets broadcast by each host on the network once a minute.

       Machines for which no status report has been received for 5 minutes are shown as being down.

Options
       -a   Users idle an hour or more are not counted unless this option is specified.

       -d   Display only those hosts that are considered down.

       -l   Sort the status list by load average.  If more than one sort option is given, uses the last one.

       -r   Show only hosts that are up and running.

       -t   Sort the status list by uptime.  If more than one sort option is given, uses the last one.

       -u   Sort the status list by number of users.  If more than one sort option is given, uses the last one.

       -nn  Show only those hosts with nn or more users.

Restrictions
       Because the daemon sends its information in broadcast packets it generates a large amount of network traffic.  On large networks the  extra
       traffic	may  be  objectionable.   Therefore,  the  daemon is disabled by default.  To make use of the daemon for both the local and remote
       hosts, remove the comment symbols (#) from in front of the lines specifying in the file.

       If the daemon is not running on a remote machine, the machine may incorrectly appear to be down when you use the command to  determine  its
       status.	See the reference page for more information.

       If  a  system  has  more  than 40 users logged in at once, the number of users displayed by the command is incorrect.  Users who login to a
       machine after that point fail to increment the user count that appears in the output of the command.  This is due to the maximum size limit
       of an Ethernet packet, which is 1500 bytes, and the fact that the daemon must broadcast its information in a single packet.

Files
       /usr/spool/rwho/whod.*	Information about other machines

See Also
       rwho(1c), rwhod(8c)

																       ruptime(1c)
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy