Sponsored Content
Top Forums Shell Programming and Scripting How to delete a particular text without opening the file. Post 82121 by vino on Monday 29th of August 2005 05:57:58 AM
Old 08-29-2005
Quote:
Originally Posted by stevefox
Thanks Nir!

That command did delete the second line but it still contained " ;" for lines one and three.

I added an extra command to get rid of the " ;" for lines one and two as well.

sed -e '/b ;/d' mytext.txt | sed -e 's/ ;//' > mytext.txt.new


Thanks for your help.

Cheers
Steve
Avoid using sed twice. Instead give two different scripts with one sed.

Give it as

Code:
sed -e "s/;$//g" -e "/b/d" mytext.txt > mytext.txt.new

vino
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to delete away text in a file?

I have this xml file which is call p.txt and it contains the follwing: 16:13:56 Msg send to Queue=<pregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <system_c>HPREGATE</system_c> <trans_c>HSPG</trans_c> <trans_dt>20060105161333</trans_dt> <user_id_m></user_id_m> ... (5 Replies)
Discussion started by: forevercalz
5 Replies

2. UNIX for Dummies Questions & Answers

delete file without opening vi

hi there guys, wonder if any gurus can help me out on this one... try searching the past threads but cant find anything. i have this huge file but when i use vi to open it it gives me the following error: <"pmrepserver.txt""/var/tmp/Ex86200" There is not enough space in the file... (7 Replies)
Discussion started by: lweegp
7 Replies

3. UNIX for Dummies Questions & Answers

Urgent help needed to delete some text without opening the file in unix

Hi To delete some text in 2 files in line1 ( not complete line) in unix without opening the files. For example: source file is like this <?xml version="1.0"... (5 Replies)
Discussion started by: pyaranoid
5 Replies

4. Shell Programming and Scripting

How to Delete string without opening a file

Hi Experts, I have several big size file arround 900 MB. From the file I need to delete some common strings but without opening the file. here is example- in file <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="8423b5ae190810252359350480/1/1/1"> ... (6 Replies)
Discussion started by: thepurple
6 Replies

5. Web Development

opening text files with javascript

Im aware under IE, javascript uses ActiveX Objects to open up and manipulate text files, excel files etc.. How abouts would I open a text file using javascript in Firefox ? thanks (1 Reply)
Discussion started by: JamesGoh
1 Replies

6. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies

7. Shell Programming and Scripting

How to delete lines of a text file based on another text file?

I have 2 TXT files with with 8 columns in them(tab separated). First file has 2000 entries whereas 2nd file has 300 entries. The first file has ALL the lines of second file. Now I need to remove those 300 lines (which are in both files) from first file so that first file's line count become... (2 Replies)
Discussion started by: prvnrk
2 Replies

8. UNIX for Dummies Questions & Answers

^H characters appear when opening text file using vi - RHEL

Version Info: $ cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.8 (Tikanga) $ $ uname -a Linux stryker138 2.6.18-308.13.1.el5 #1 SMP Thu Jul 26 05:45:09 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux I redirected manpage of ksh command's output to a text file as shown... (6 Replies)
Discussion started by: kraljic
6 Replies

9. UNIX for Dummies Questions & Answers

How to read a file without opening the file and delete last line?

I have file called "text". The contents are as below : aaa bbb ccc ddd eee ffff ddd hhhh iiii I want to read this file without opening and and delete the last line. How can it be done? (4 Replies)
Discussion started by: the_hunter
4 Replies

10. UNIX for Dummies Questions & Answers

Delete records based on a text file from a text file

Hi Folks, I am a novice and need to build a script in bash. I have 2 text files data.txt file is big file, column 2 is the we need to search and delete in the output. The filter file contains the rows to be deleted. Data.txt state city zone Alabama Huntsville 4 California SanDiego 3... (3 Replies)
Discussion started by: tech_frk
3 Replies
POLICY.PY(5)							  [FIXME: manual]						      POLICY.PY(5)

NAME
policy.py_ - zorp(8) policy file. DESCRIPTION
The policy.py file is a Python module containing the zone and service definitions and other policy related settings used by zorp(8). Empty lines and lines beginning with '#' are comments and are ignored. The policy.py file is generated automatically by ZMC, the Zorp Management Console, or it can be edited manually. IMPORTANT: Do not edit manually a file generated by ZMC, because the manual changes will not be retained by ZMC and will be lost when re-generating the file. FILES
The default location of policy.py is /etc/zorp/policy.py. SEE ALSO
For further information on policy.py refer to the following sources: A tutorial on manually editing the policy.py file can be found at http://www.balabit.com/network-security/zorp-gateway/gpl/tutorial/[1]. Additional information can also be found in the Zorp Administrator's Guide, the Zorp Reference Guide, and in the various tutorials available at the BalaBit Documentation Page at http://www.balabit.com/support/documentation/[2]. AUTHOR
This manual page was written by the BalaBit Documentation Team <documentation@balabit.com>. COPYRIGHT
Copyright (C) 2006 BalaBit IT Security Ltd. All rights reserved. For more information about the legal status of this document please read: http://www.balabit.com/products/zorp/docs/legal_notice.bbq NOTES
1. http://www.balabit.com/network-security/zorp-gateway/gpl/tutorial/ http://www.balabit.com/network-security/zorp-gateway/gpl/tutorial/ 2. http://www.balabit.com/support/documentation/ http://www.balabit.com/support/documentation/ [FIXME: source] 03/06/2012 POLICY.PY(5)
All times are GMT -4. The time now is 03:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy