I was playing around in my terminal earlier and discovered that I can execute single word commands (‘ls’,’cat’,’python2.7′,’exit’) by making a file or directory named the same thing as the command. However, I can’t execute ‘multi-word’ commands (‘rm -rf *’,’ls -a’, ‘python2.7 test.py’) (which also led me to discover that you can’t remove directories named ‘-rf’ with ‘rm -rf *’)
Tag: shell
Unable to get correct output in linux script
I wanted to get the remaining(free) percentage of RAM usage as output storing in variable for further processing. Instead m getting $ac output as Please help Answer works fine for me. (BTW, awk can do grep’s work too: )
Why count differs between ls and ls -l linux command?
I had a directory with number of files and need to check the count of files present in it. I tried the following two commands: and found there are differences while using both commands. (ie. number of files is greater in the usage of second command while comparing to the first command.) I would like to know the changes happening
Pass argument to awk inside do loop
I have a large number of tab-separated text files containing a score I’m interested in in the second column: test_score_1.txt test_score_2.txt I want to check if I have Titles with a score smaller than a number I define. The following code defines my score in the script and works: check_score_1 If I try to pass an argument to awk like
Gnu sort: stray characters in field specification
sort doesn’t seem to like my key specification. Why? From the man page: -k, –key=KEYDEF : sort via a key; KEYDEF gives location and type KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where F is a field number and C a character position in the field; both are origin 1, and the stop position defaults to the line’s end.
Handling Dates in FTP
Here is my ftp script The output of this script is: I googled and seen some posts regarding dates but all provided formats not worked for me. Please advise Thanks in anticipation Answer through to FTP, which can include executing commands, substituting variables, and the like. That is to say, instead of writing: ftp < ftp_args> << EOT blah bloho
Why does dollar not match literal dollar when extended regex (ERE) option is used with sed?
I want to replace $foo with bar. This works fine. But this command does not work fine when I use the -r option. Why doesn’t this work. Here is an example of what works with -r option. The real question is: Why does $ need to be escaped only while using the -r option. What would $ mean otherwise with
Correct way to set a crontab to stop and start mysql and httpd
i’m trying to create a shell script to stop and start mysql and httpd every saturday on 3am, i’m doing it: myscript.sh: and setting the crontab to: It’s correct way to do it? i’m stopping and starting mysql and httpd cuz use of memory, should i do some check before stop them? or i can do it without problems? another
How can I recursively search for multiple patterns on linux?
I am trying to find files that include either of the following two patterns: By AND, I mean a logical and. I am using the following command: to check if a file has INTO and SELECT, but this returns the string if either one exists, but I need both. Answer If the patterns have to occur on the same line,
crontab shell script starts another script: remove char error
I want to run a shell script through crontab which does something and then runs another shell script which checks a certain folder for certain files and creates a directory for each file. The first script “my_crontab.sh” looks like this: Crontab executes “my_crontab.sh” and “start.sh” gets also called (I know from the crontab log file) This is what “start.sh” looks