command-line

Bash: escape characters in backticks

I'm trying to escape characters within backticks in my bash command, mainly to handle spaces in filenames which cause my command to fail. The command I have so far is: grep -Li badword `grep -lr goodword *` This command should result in a list of files that do not contain the word "badword" but do contain "goodword". ...

Execute "less" from command-line PHP w/ Scrolling

I want to execute less and similar programs from the command-line in PHP. I have tried the usual suspects (exec, shell_exec, passthru, etc), and while many of them can dump the file to the screen, the process is terminated before I can make use of it. If I wanted cat, I'd use it. How do I execute a program in this fashion? ...

How to input into an array.

main(int c,char **args){ int i char input[100]; bzero(input,100); for(i=1;i<c;i++) { input=strcat(input,args); input=strcat(input," "); } } i have included the string.h header file.... I want the input i enter in the command line to be stored in the input array. could anyone please correct my code.. Thank you. ...

How to change the title and background color of command line program

Is it possible to change the background color and the title text of compiled command line program ? I do not have the source files. ...

Running SQL from file MySQL - User Input?

Hi All, I'm running MySQL from the command line and executing SQL stored in files. What I'm trying to do, is prompt the user to enter input so that I can include this in the SQL script? Is there a way to do this with MySQL? Many thanks, James ...

Use sed (or other command line) to replace a set of characters with a different set

I need to invert a DNA text string by changing all the A's to T's, T's to A's, C->G, and G->C. Can I elegantly handle this in sed (or other command line) without a whole chain of sed global replace commands? ...

Calling python script on MAC/Linux from Command line - passing arguments

Consider this setup and folder structure: c:\foo \bin\foo.bat \lib\foo.py I have foo.bat path added to my environment PATH, so I can call it from anywhere passing in some arguments: c:/>foo.bat -v foo.bat contains this code: @ECHO OFF "c:\foo\lib\foo.py" %1 %2 %3 %4 %5 %6 %7 %8 %9 This works fine in Windows. Now I ...

SAS Command Line shortcut

Is there a shortcut in Base SAS to provide focus to the command-line / display manager bar? ...

Creating a shorter version of a bash command

i am novice to the Linux shell and had to recently start using it for work...i have now got used to the basic commands in bash to find my way around...however there are a lot of commands i find myself typing over and over again and its kind of a hassle to type them every time...so can anyone tell me how can i shorten the command syntax f...

Looking for unix style 'getopt' command line parsing in a windows/dos batch file

Can anyone help me find something to parse command line args in a dos batch file like one would do in a unix shell script using getopt/getopts? It doesn't have to be all posix-y; just something that I can specify what switches I expect, which of them require/allow an argument. They don't need to be "long" switches; single characters wi...

unix commandline for inline replacement of all newlines in file with <br>\n

sed 's/$/<br>/' mytext.txt worked but output it all on the command line. I want it to just do the replacement WITHIN the specified file itself. Should I be using another tool? ...

How to count number of unique values of a field in a tab-delimited text file?

I have a text file with a large amount of data which is tab delimited. I want to have a look at the data such that I can see the unique values in a column. For example, Red Ball 1 Sold Blue Bat 5 OnSale ............... So, its like the first column has colors, so I want to know how many different unique values are there in th...

How to automatically list directory contents after a CD command?

Hi all, I would like to create a new unix command to automatically list the contents of a directory after a CD command. So far, I've tried several things: alias cdls='cd $1 | ls -l' function cdls(){ cd $1; ls -l;} Both perform the listing but dont change the working directory. Thanks. ...

Change attributes of a group of files in MS-DOS

The MS-DOS command attrib changes the attributes of a single file. How can I use it to change the attributes of a group of files? ...

Running R Code from Command Line (Windows)

I have some R code inside a file called analyse.r. I would like to be able to, from the command line (CMD), run the code in that file without having to pass through the R terminal and I would also like to be able to pass parameters and use those parameters in my code: eg. C:>(execute r script) analyse.r C:\file.txt and this would execu...

What's the opposite of head? I want all but the first N lines of a file.

Given a text file of unknown length, how can I read, for example all but the first 2 lines of the file? I know tail will give me the last N lines, but I don't know what N is ahead of time. So for a file AAAA BBBB CCCC DDDD EEEE I want CCCC DDDD EEEE And for a file AAAA BBBB CCCC I'd get just CCCC ...

Java execute jar which depends on other jar from command line

Hi, I have an application that uses an external jar. I used eclipse and it works fine. I export as jar from eclipse, having created a Manifest file that has as Class-Path: ./cab.v1.jar I place both jars in the same directory. I run in command line: java -jar myApp.jar and get java.lang.NoClassDefFoundError for the classes in the cab.v1...

Sorting in bash

I have been trying to get the unique values in each column of a tab delimited file in bash. So, I used the following command. cut -f <column_number> <filename> | sort | uniq -c It works fine and I can get the unique values in a column and its count like 105 Linux 55 MacOS 500 Windows What I want to do is instead of sorting by th...

Compiling multiple packages using the command line in Java

Hi i have been using an IDE but now I need to run and compile from the command line. The problem is that I have multiple packages and I have tried to find the answer but nothing has worked. So I have src/ Support/ (.java files) Me/ (.java files) Wrapers/ (.java files) Do you know how to compile everything with javac? ...

How to start an external program with a file from a C program when both paths have spaces?

I'm trying to fix an existing C-program with VS2005 that eventually calls int system(command) //in C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\system.c) with parameter value start C:\Program Files\VideoLAN\VLC\vlc.exe C:\Documents and Settings\me\My Documents\My Music\09 - Track09.mp3 the program to be started and the ...