More Shell problems

Alex Papadopoulos apapadop at cmu.edu
Mon Mar 24 03:54:03 EET 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 23 March 2003 19:04, Nicolas Greece wrote:
> Kalimera se olous kai pali. Meta apo ena SK sklirou
> diavasmatos, erxomai me perissoteres apories...
>
> Ksekiname...
>
> 1.
> sto Home otan dino (ls |sort) ginete kanonika sort
> alla otan kano ls | sort  /home/Nicolas/Lab/ mou leei
> oti einai directory

Prwta prepei na kaneis list to directory pou 8es, kai meta pipe sto sort.

>
> Pos boro
> a) na kano sort directories
> b) na kano sort arxeia mesa se directories (opos thelo
> pio pano?)

Dokimase ls /home/mpla/ | sort

Shmeiwsh to ls kanei apo mono tou diafora sortarismata kai ayto pou kaneis 
einai pi8anotata peritto - man ls

>
> 2.
> Ftiaxno ena script me arguments arg1, arg2, arg3
> klp...
> Dino /home/nicolas/arg Nikos Nikolaou ilias kai
> doulevei
>
> Otan pao na to kano output na sothei den tha prepei na
> tou doso
> /home/nicolas/arg Nikos Nikolaou ilias -o
> /home/nicolas/name.txt?
>
> Giati kai edo den benei sto arxei pou thelo?

An milas gia shell script, prepei na xrhsimopoihseis shell redirects. Rixneis 
mia matia sto http://tldp.org/LDP/abs/html/io-redirection.html
Mallon ayto pou 8es einai to /home/mpla/script > /home/mpla/output.txt

>
> 3.
> a) Sta shell Variables gia to csh einai
>    Set my_string1="Hallo" (gia string)
>    gia to bash?

export my_string1="Hallo"

> b) Sta shell Variables gia to csh einai @ x=7
>    (alfarithmitiko)
>    gia to bash?

export x=7

<snip>

Gia to make den kserw

> 5.
> exei parousiastei ena arxeio me onoma #greetings# kai
> me rm den svinei. Ti
> einai afto to arxeio kai giati ginete afto?
>

backup file kapoiou editor (den 8ymamai twra poios ap'olous)
An grapseis rm \# kai pathseis TAB, 8a mporeseis na to sbhseis (prepei na 
krypseis to special character # apo to shell)


> 6.
> Kanena vivliaraki kainourio eiparxei se sxesi me afta
> pou asxoloume? Exo idi parei (proxtes) to Unix in a
> nutshell alla me mathimata kai paradeigmata as
> poume...

Gia to scripting pou prospa8eis na kaneis, to link pou sou egrapsa parapanw 
(Advanced Bash Scripting Guide) einai mia xara. Koita genika sto tldp.org 
exei poly pragma, sta arxeia ths listas gia ena thread tou styl "online 
books" kai sto <SHAMELESS_PLUG>
http://www.andrew.cmu.edu/~apapadop/personal/bookmarks.html 
</SHAMELESS_PLUG> sto prwto section "Reading" gia diafora links pou 
xrhsimopoiw egw.

- -A
- -- 
http://andrew.cmu.edu/~apapadop/pub_key.asc
3DAD 8435 DB52 F17B 640F  D78C 8260 0CC1 0B75 8265
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+fmWYgmAMwQt1gmURAqL9AJwMch+icAnz+12xxM42uKTvkSkO0ACeLFDa
U/Fek98wQhcs2GCDTgd4OaE=
=vGaA
-----END PGP SIGNATURE-----




More information about the Linux-greek-users mailing list