Jump to content
xisto Community
HannahI

Tips: Unix Commands

Recommended Posts

Let's share UNIX commands.

To start off, here are some.

function - create a function - Syntax: function myfunction() {

echo - print - syntax: echo hello

-Hannah

Share this post


Link to post
Share on other sites

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").

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
echo "hello"
or
string hello = "Hello there";echo hello;

But it all depends on which language/environment you're using :D

Share this post


Link to post
Share on other sites

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 $SHELLHere are some more commands which are commonly used:tput clear# Clears screenls -l > list#Saves the list of files and directories in the current directory with attributes (-l) in "list" file.cat filename# Display file contentswc list# Counts number of lines. x lines, x words, x charactersAnything starting with hypen (-) is an option. It needs to be separate, that is no characters after or before it.

Share this post


Link to post
Share on other sites

tput clear# Clears screen

Talking about tput, another interesting one is

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.