How can I create an empty file at the command line in Windows?

Without redirection, Luc Vu or Erik Konstantopoulos point out to: copy NUL EMptyFile.txt copy /b NUL EmptyFile.txt “How to create empty text file from a batch file?” (2008) also points to: type NUL > EmptyFile.txt # also echo. 2>EmptyFile.txt copy nul file.txt > nul # also in qid’s answer below REM. > empty.file fsutil file … Read more

Run R script from command line

If you want the output to print to the terminal it is best to use Rscript Rscript a.R Note that when using R CMD BATCH a.R that instead of redirecting output to standard out and displaying on the terminal a new file called a.Rout will be created. R CMD BATCH a.R # Check the output … Read more

What does the number in parentheses shown after Unix command names in manpages mean?

It’s the section that the man page for the command is assigned to. These are split as General commands System calls C library functions Special files (usually devices, those found in /dev) and drivers File formats and conventions Games and screensavers Miscellanea System administration commands and daemons Original descriptions of each section can be seen … Read more

How to pretty print XML from the command line?

xmllint This utility comes with libxml2-utils: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xmllint –format – Perl’s XML::Twig This command comes with XML::Twig perl module, sometimes xml-twig-tools package: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xml_pp xmlstarlet This command comes with xmlstarlet: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xmlstarlet format –indent-tab tidy Check the tidy package: echo … Read more

How can I use grep to find a word inside a folder?

grep -nr ‘yourString*’ . The dot at the end searches the current directory. Meaning for each parameter: -n Show relative line number in the file ‘yourString*’ String for search, followed by a wildcard character -r Recursively search subdirectories listed . Directory for search (current directory) grep -nr ‘MobileAppSer*’ . (Would find MobileAppServlet.java or MobileAppServlet.class or … Read more

How do I parse command line arguments in Java?

Check these out: http://commons.apache.org/cli/ http://www.martiansoftware.com/jsap/ Or roll your own: http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html For instance, this is how you use commons-cli to parse 2 string arguments: import org.apache.commons.cli.*; public class Main { public static void main(String[] args) throws Exception { Options options = new Options(); Option input = new Option(“i”, “input”, true, “input file path”); input.setRequired(true); options.addOption(input); Option … Read more

Adding a directory to the PATH environment variable in Windows

Option 1 After you change PATH with the GUI, close and re-open the console window. This works because only programs started after the change will see the new PATH. Option 2 This option only affects your current shell session, not the whole system. Execute this command in the command window you have open: set PATH=%PATH%;C:\your\path\here\ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)