Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell command advice #115

Closed
AntoineD opened this issue Mar 28, 2014 · 9 comments
Closed

Shell command advice #115

AntoineD opened this issue Mar 28, 2014 · 9 comments

Comments

@AntoineD
Copy link
Contributor

Hi Tomer,
what would be a good way to implement this command

diff <(sed 's/pattern//g' file1) <(sed 's/pattern//g' file2)

where pattern, file1 and file2 would change from one execution to another?

@tomerfiliba
Copy link
Owner

def mydiff(file1, file2, pattern):
    return diff(sed("s/%s//g" % (pattern), file1), sed("s/%s//g" % (pattern), file2))

?

@AntoineD
Copy link
Contributor Author

This is what I tried at first, but it does not work, the diff comand issues a "No such file or directory" error.

@tomerfiliba
Copy link
Owner

Because you have to first redirect the output of sed to a file for diff to
work. I guess you could implement that behavior in plumbum, but I never did
On Mar 29, 2014 4:54 PM, "Antoine Dechaume" notifications@github.com
wrote:

This is what I tried at first, but it does not work, the diff comand
issues a "No such file or directory" error.


Reply to this email directly or view it on GitHubhttps://github.com//issues/115#issuecomment-38996132
.

@AntoineD
Copy link
Contributor Author

I was trying to avoid temporary files, but I can live with them as well.
Thanks Tomer.

@AntoineD
Copy link
Contributor Author

So I'm trying to redirect sed output to a file and I'm really puzzled, I cannot get it working.
What I understand from the docs is that the following should create a file named foo with the contents of ls

from plumbum.cmd import ls
ls() > 'foo'

But I get no file.

Am I doing it all wrong?

@AntoineD AntoineD reopened this Mar 31, 2014
@tomerfiliba
Copy link
Owner

use (ls > "foo")()

don't forget the () operator runs the process. to create redirections,
etc., you have to first operate on the command object, then execute it.


Tomer Filiba
tomerfiliba.com http://www.facebook.com/tomerfiliba
http://il.linkedin.com/in/tomerfiliba

On Mon, Mar 31, 2014 at 5:04 PM, Antoine Dechaume
notifications@github.comwrote:

So I'm trying to redirect sed output to a file and I'm really puzzled, I
cannot get it working.
What I understand from the docs is that the following should create a file
named foo with the contents of ls

from plumbum.cmd import ls
ls() > 'foo'

But I get no file.

Am I doing it all wrong?


Reply to this email directly or view it on GitHubhttps://github.com//issues/115#issuecomment-39091648
.

@AntoineD
Copy link
Contributor Author

Thanks Tomer.
I think I got a little confused by the doc, such a simple example could be added for dumb people like me :-)

@tomerfiliba
Copy link
Owner

why, it's in the cheat sheet:

http://plumbum.readthedocs.org/en/latest/, under "redirection"


Tomer Filiba
tomerfiliba.com http://www.facebook.com/tomerfiliba
http://il.linkedin.com/in/tomerfiliba

On Mon, Mar 31, 2014 at 5:15 PM, Antoine Dechaume
notifications@github.comwrote:

Closed #115 #115.


Reply to this email directly or view it on GitHubhttps://github.com//issues/115
.

@AntoineD
Copy link
Contributor Author

I know, and now it seems obvious, but the fact is I've been struggling with it, and my feeling is that starting off by a simple example without multiple redirections, pipe or bound argments would help some people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants