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


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Urgent help needed to delete some text without opening the file in unix
# 1  
Old 06-24-2008
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
Code:
<?xml version="1.0" encoding="UTF-8"?><file-header><source-id>wRLCSSAM</source-id><file-date>2008-06-23</file-date><file-time>05:45:29</file-time></file-header>

and i want the output file as

Code:
<file-header><source-id>wRLCSSAM</source-id><file-date>2008-06-23</file-date><file-time>05:45:29</file-time></file-header>

Thanks in advance

Last edited by Yogesh Sawant; 06-25-2008 at 02:43 AM.. Reason: added code tags
# 2  
Old 06-24-2008
Quote:
Originally Posted by pyaranoid
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" encoding="UTF-8"?><file-header><source-id>wRLCSSAM</source-id><file-date>2008-06-23</file-date><file-time>05:45:29</file-time></file-header>

and i want the output file as

<file-header><source-id>wRLCSSAM</source-id><file-date>2008-06-23</file-date><file-time>05:45:29</file-time></file-header>

Thanks in advance
Code:
sed -n -e "s/<.xml version=[^>]*>\(.*\)/\1/p" input.txt > output.txt

# 3  
Old 06-24-2008
This is not working. PLease advise.

Thanks
# 4  
Old 06-24-2008
Hammer & Screwdriver check this

make sure that all the files which need to be edited are in current directory
Code:
for i in `ls`
do
sed -e 's@<?xml version="1.0" encoding="UTF-8"?>@@g' $i >temp; mv temp $i;
done

Good Luck !!!

Last edited by Yogesh Sawant; 06-25-2008 at 02:44 AM.. Reason: added code tags
# 5  
Old 06-24-2008
Vino's code is working GNU sed and AIX's sed.
# 6  
Old 06-25-2008
Quote:
Originally Posted by pyaranoid
This is not working. PLease advise.

Thanks
If you care to share what is not working, or if you can tell us the error you encountered, then we can help you out.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Programming

Wrapper for unix program - urgent help needed

Hello all , i need some help asap i have a program that keeps killing the machine when i did google searches and 2 days later i ran strace it seems the programm keeps making a system call to gettimeofday to i guess increment a counter ? gettimeofday({1347986584, 464904}, NULL) = 0... (6 Replies)
Discussion started by: NetworkLearning
6 Replies

3. Shell Programming and Scripting

urgent help needed regarding splitting file

how can i split a file on last record ? say i have a file A with 4 records as follows : first line second line third line last line I want to make two files B and C with contents of B as first line second line third line and the contents of C as last line (8 Replies)
Discussion started by: aliyesami
8 Replies

4. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

5. 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

6. Shell Programming and Scripting

How to delete a particular text without opening the file.

Hi, Could someone tell me how to delete a particular text inside an existing file without opening the file? e.g. I have a text file called mytext.txt which contains three lines of text below and I want to delete “ ;” and delete the second line “b ;” including the carriage return. a ; b ; c ;... (12 Replies)
Discussion started by: stevefox
12 Replies

7. UNIX for Dummies Questions & Answers

Unix book (urgent help needed)

hi guys i am new to UNIX and i am very much excited to learn how it works.. i was very confused with how to start and what book to follow so i went to my lecturer and asked him if he could suggest something. he advised me to get this book Your UNIX: The Ultimate Guide by "Sumitabha Das" ISBN:... (4 Replies)
Discussion started by: prabhashkashyap
4 Replies

8. Shell Programming and Scripting

Urgent help required in deleting a line without opening a file usinga shell script

Hi, I need a help in deleting a line matching a particular pattern in a file using shell script without opening the file. The file is a .c/.cpp file. Is it possible? Thanks (6 Replies)
Discussion started by: naan
6 Replies

9. 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

10. UNIX for Dummies Questions & Answers

Urgent answer needed, please: help with a text editor

I'm sorry if this has been posted before, but I'm in a big hurry and I need a pretty quick answer: I have to make a project for school which consists of many BASH scripts. At school we have Sun Sparcs. During the laboratory hours I used to open the text editor (in the graphics interface), edit the... (4 Replies)
Discussion started by: MtFR
4 Replies
Login or Register to Ask a Question