Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:27:48+00:00 2026-05-31T03:27:48+00:00

I have one file /tmp/test.txt this is test that is test When I run

  • 0

I have one file /tmp/test.txt

this is test
that is test

When I run

[test@localhost]# grep "this is" /tmp/test.txt 
this is test

I got the output.

When I try to run same command with subprocess I didn’t get the output. It also return the code 1.

import subprocess
p = subprocess.Popen(['grep', '"this is"', '/tmp/test.txt'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

print p.communicate ()
('', '')

# Command exit code.
print p.poll()
1

I also check the answers Python Subprocess Grep in this and tried shell=True but its not working.

I am missing to place something in subprocess to get the output, but what I dont know :(.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:27:50+00:00Added an answer on May 31, 2026 at 3:27 am

    You’re searching for the literal pattern "this is", including the quotes. Change the second element in the command list to 'this is' rather than '"this is"'.

    Quoted arguments are only needed when shell=True, in which case the shell interprets them and still passes this is, without quotes, to grep.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is driving me crazy. I have this one php file on a test
I have problem with session in cakephp.I have one file chat.php that is in
I have one audio file captured from my iphone. I want to upload this
I have one method that opens a file and passes off to another function
I have one file in my project, (the readme file,) which I would like
I used to have one class for one file. For example car.cs has the
I have one xsd file I'd rather not modify (Exceptions.xsd): <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns=http://me.com/Exceptions.xsd targetNamespace=http://me.com/Exceptions.xsd
i have one php file which process adding of record in Database fro array.
I have just one cs file in my repository which Git seems to think
I have one PHP script that has to start a second script in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.