LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2011, 03:46 PM   #1
tao_goldi
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
Sed with python os.system()


Hello All,

I need help please. I am trying the execute the following

#!/usr/bin/python
import os

os.system("sed -e 's#^\(.*\)\t\(.*\)0http://\1\2#' t2.txt > t3.txt")

os.system("cat t3.txt | sort | uniq -c | sort -rn | head > t4.txt")

But I receive the following error message.

sed: -e expression #1, char 27: unterminated `s' command

any ideas? Please help
 
Old 02-03-2011, 04:10 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I think using os.system to do that is really pretty horrible, If you're using python, then use python code to do this natively, and maintain full control over what's going on. os.system() will not help you control your program flow. As for what's wrong though, you've not got two parts to the s command, as it says. you have a # at either end, replacing a conventional / (didn't know you could do that... thanks!) but nothing in the middle, so it's all just interpreted as the first half.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python eqivalent of sed file conversion pppaaarrrkkk Programming 2 03-02-2010 07:17 PM
python, os.system() function. howto use python variables? jhwilliams Programming 5 07-28-2007 01:56 AM
LXer: Next Up on the System i: Python LXer Syndicated Linux News 0 04-17-2006 07:21 AM
python os.system arguments randomx Programming 2 03-03-2005 03:54 PM
python alternative to os.system() datadriven Programming 5 02-27-2005 07:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration