Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Calling Linux's "cat" command using -shell- in Stata MP 12
From
Richard Herron <[email protected]>
To
[email protected]
Subject
st: Calling Linux's "cat" command using -shell- in Stata MP 12
Date
Mon, 4 Jun 2012 14:30:09 -0400
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/