Astahost.com   Mar 21, 2010
Open Discussion & Free Web Hosting > Computers & Tech > Operating Systems > UNIX (Other Flavours)

Tips: Unix Commands

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Operating Systems > UNIX (Other Flavours)

Tips: Unix Commands

HannahI
Let's share UNIX commands.
To start off, here are some.
  • function - create a function - Syntax: function myfunction() {
  • echo - print - syntax: echo hello

-Hannah

Comment/Reply (w/o sign-up)

wutske
You're talking about writing a BASH script, right ?
Because "UNIX commands" is a very vague description which I interpret as commands to start an application (eg "ping 127.0.0.1").

Comment/Reply (w/o sign-up)

yordan
QUOTE (HannahI @ Oct 29 2009, 08:35 PM) *
function - create a function - Syntax: function myfunction() {

and also, please, when you give such an info, give it completely.
I'm pretty sure the heading "{" needs a trailing "}" in order the function description to be complete.

Comment/Reply (w/o sign-up)

wutske
QUOTE (yordan @ Oct 31 2009, 05:04 PM) *
and also, please, when you give such an info, give it completely.
I'm pretty sure the heading "{" needs a trailing "}" in order the function description to be complete.


Now that we're talking about mistakes. Usualy a string is places between " " , unless hello is a previously defined variable.
So it should probably be
CODE
echo "hello"

or
CODE
string hello = "Hello there";
echo hello;


But it all depends on which language/environment you're using wink.gif

 

 

 


Comment/Reply (w/o sign-up)

Spencer
In Unix I have observed the following two statements give the same results:
CONSOLE
echo $SHELL

CONSOLE
echo "$SHELL"

Both the methods will process the variable and prints which shell is running.

To take the input as text, whether or not there are variables included, it would be included in single quotes
CONSOLE
echo '$SHELL'

The output would be $SHELL

Here are some more commands which are commonly used:
tput clear
# Clears screen

ls -l > list
#Saves the list of files and directories in the current directory with attributes (-l) in "list" file.

cat filename
# Display file contents

wc list
# Counts number of lines. x lines, x words, x characters

Anything starting with hypen (-) is an option. It needs to be separate, that is no characters after or before it.

Comment/Reply (w/o sign-up)

yordan
QUOTE (Spencer @ Nov 1 2009, 10:51 AM) *
tput clear
# Clears screen

Talking about tput, another interesting one is
QUOTE
tput sgr0

This resets your terminal to standard values, removing "rev", "blink" and other disagreeable features you got if you "cat" a binary file to your display.

Comment/Reply (w/o sign-up)

HannahI
Yes, Yes, Yes and Yes.
Now I'm actully learning something! biggrin.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)




See Also,

*SIMILAR VIDEOS*
Searching Video's for Tips:, Unix, Commands
advertisement




Tips: Unix Commands

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com



Creative Commons License