Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Richard Herron <richard.c.herron@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Calling Linux's "cat" command using -shell- in Stata MP 12 |
Date | Tue, 5 Jun 2012 14:40:12 -0400 |
You're correct, Phil. That does it! Thanks! Richard Herron On Tue, Jun 5, 2012 at 2:52 AM, Phil Clayton <philclayton@internode.on.net> wrote: > > I haven't got my Linux installation in front of me but on the Mac each -shell- command runs independently, starting its own session - so the "cd" from the first command won't apply to the second command. > > Try something this instead: > > * begin code > shell cd ~/data/txt/board_ownership; cat *_2.txt > board_ownership.txt > * end code > > Phil > > On 05/06/2012, at 4:30 AM, Richard Herron wrote: > > > I am trying to use -shell- in Stata MP 12 to call "cat" in Linux to > > concatenate a directory of 800 tab-delimited text files. The > > tab-delimited text files all end in _2.txt and should match the wild > > card *_2.txt. I tried two variants, which both fail. First I tried: > > > > * begin code > > shell cd ~/data/txt/board_ownership > > shell cat *_2.txt > board_ownership.txt > > * end code > > > > which fails with "cat: *_2.txt: No such file or directory". However, > > in the Stata console, if I -shell- to get the command prompt, then I > > can successfully issue the "cd" and "cat" commands. I get the same > > result if I replace the wild card * with an existing file. > > > > Second I tried > > > > * begin code > > shell cat "~/data/txt/board_ownership/*_2.txt" > > > "~/data/txt/board_ownership/board_ownership.txt" > > * end code > > > > which fails with "/bin/bash: > > ~/data/txt/board_ownership/board_ownership.txt: No such file or > > directory" > > > > Can I automate this from within Stata? Or is this best done explicitly > > in the command line? > > > > Thanks! > > > > Richard Herron > > * > > * For searches and help try: > > * http://www.stata.com/help.cgi?search > > * http://www.stata.com/support/statalist/faq > > * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/