Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13510 > unrolled thread
| Started by | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| First post | 2013-02-16 06:08 +0000 |
| Last post | 2013-04-10 04:48 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Executing external command with parameters Bill Rowe <readnews@sbcglobal.net> - 2013-02-16 06:08 +0000
Re: Executing external command with parameters debguy <johnandsara2@cox.net> - 2013-04-10 04:48 +0000
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Date | 2013-02-16 06:08 +0000 |
| Subject | Re: Executing external command with parameters |
| Message-ID | <kfn7ot$qbc$1@smc.vnet.net> |
On 2/15/13 at 1:58 AM, ramiro.barrantes@gmail.com (Ramiro) wrote:
>I would like to get a random line from a file, I know this can be
>done with Mathematica but I am playing with using sed to see if it
>goes faster, say I want to get line 1000
>In mathematica it would be:
><<"! sed -n p1000 filename.txt"
>However, I am trying to put the filename as a variable, say
>filename="hugefile.txt"
>cmd="! sed -n p1000 "<>filename <<cmd
>does not work.
>How can I do this?
Here is how I do something very similar to what you've indicated
you are trying to do
bbedit[filename_String]:=Run["bbedit", "'"<>filename<>"'"]
bbedit[]:=Run["bbedit", "'"<>Directory[]<>"'"]
bbedit[filename_String, switches__]:= Run["bbedit", switches, StringJoin@@{"'",filename,"'"}]
This function runs a command line utility that passes the file
(filename) to my favorite text editor for editing.
[toc] | [next] | [standalone]
| From | debguy <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-10 04:48 +0000 |
| Message-ID | <kk2qur$bi8$1@smc.vnet.net> |
| In reply to | #13510 |
$ cat file | head -n1000 | tail -n1
$ cat file | awk '{ if( ++n >= 1000 ){ print $0 ; exit ; } }'
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web