2014-02-16

A-Z Of Bash Commands For Bash Learner

බොහෝ වැදගත් වන ලිනකස් කමාන්ඩ්ස් 

A
alias: If creating an alias is what you want, then this is it.
apropos: We’re not the only ones providing help. This command you to search through the Help manual pages.
apt-get: This one works on Debian and Ubuntu distros. It is used to install and search for software packages.
aptitude: See the similarity with the above command? This one does the same thing.
aspell: Got bad spellings? Use the spell checker.
awk:No, this command is not for awkward situations. It lets you find text and replace it. Also, you can sort, index and validate things in a database.

B
basename: Sometimes files and directories have suffixes to their names. This one strips them off it.
bash: GNU Bourne-Again Shell
bc: This command is an arbitrary precision calculator language 
bg: bg could stand for background couldn’t it? Regardless, that’s what it does, sends to the background
break: Exit from a loop
builtin: Run a shell builtin
bzip2: When there’s ‘zip’ in the name, that’s what it does. It compresses or decompresses files that are named.

C
cal: Need a calendar? This command displays one.
case: In ‘case’ you want to perform a command conditionally. This is how to do it.
cat: In programming, ‘cat’ usually stands for concatenate. Here too, but this command displays the content of the files after concatenation.
cd: Change Directory
cfdisk: In Linux, this command is the partition table manipulator
chgrp: This is how you change the ownership of a group.
chmod:‘Ch’ is for change. This one changes the access permissions.
chown: This one sounds too much like clown! Anyway, it’s not funny though. It changes the owner and group of a file.
chroot: Using this you can run a command, but with a different root directory
chkconfig System services (runlevel)
cksum: It displays the CRC checksum ad byte counts.
clear: If you need to clear the terminal screen, use this command.
cmp: Compare two files
comm: Compare two sorted files line by line
command: Run a command - ignoring shell functions
continue: This is for resuming the next iteration of a particular loop.
cp: Make a copy of files to a different location.
cron: Daemon to execute scheduled commands
crontab: Scheduling is sometimes very important. This command does it, it schedules a command that will run at a specified time.
csplit: Split a file into context-determined pieces
cut: When you need to cut down a file into parts, this is the command to use.

D

date: Use this command to change the date and time.
dc: The command stands for Desk Calculator.
ddrescue: Like most other such commands, this is the disk recovery tool.
declare: This command is used to declare the variables and to give attributes.
df: When you want to know the free space on your disk, use this.
diff: This command prints the differences between two files.
diff3: This is the same command as the previous one, but for three files.
dig: Need to lookup the DNS? Use this.
dir: Use this command for listing directory contents briefly.
dircolors: This command is used for colour setup for the ‘ls’ command.
dirname: Use this command to change a full pathname into just a path.
dirs: This command shows you the list of directories that are remembered.
dmesg: Use this command when you want to print kernel and driver messages.
du: Use this command to get an estimation of the file space usage.

E

echo: This command is used for displaying message on the screen.
egrep: This searches for files that have lines matching an extended expression.
eject: Use this when you need to eject a removable media.
enable: Use this to disable or enable bulletin shell commands.
env: Environment variables
ethtool: Ethernet card settings
eval: This command is used when you need to evaluate a many commands.
exec: For executing a command.
exit: Exiting the shell.
expand: This command converts all the tabs to spaces.
export: This command sets an environment variable.
expr: Some evaluate commands, this evaluates expressions.

F

false: Do nothing, unsuccessfully
fdformat: This command is used for low level format of a floppy disk.
fdisk: This is a partition table manipulator for Linux systems.
fg: This command is used for sending a task to the foreground.
fgrep: Use this command to search through files for tasks that match a string.
file: This is used to determine the file type.
find: This is used to find files that match a desired criteria.
fmt: This is used for reformatting paragraph text.
fold: The name is quite suggestive, it wraps text in order to fit a certain width.
format: This simply formats tapes or disks.
free: Use this to see the memory usage.
fsck: This is used for checking the consistency of the file system and repair it.
fuser: This command identifies and kills the process accessing a file.

G

gawk: This command is used to find text within files and replace it.
getopts: Parse positional parameters
grep: Through this you can search in files for lines matching a certain pattern.
groupadd: Use this command to add security user groups.
groupdel: This one is used for deleting a certain group.
groupmod: While the last one deletes, this one modified a group.
groups: Print the names of groups in which an user is located.
gzip: This command is used for compressing and decompressing files.

H

hash: This command is used to refer to the complete pathname of a name argument.
head: Use this for output for the first part of files.
help: Display the built in help for a command.
history: Command History
hostname: Print or set system name

I

iconv: Use this to convert the character set in files.
id: Display the group ids or user ids.
if: Conditional command.
ifconfig: Used to configure network interfaces.
ifdown: Use this command for stopping a network interface. 
ifup: Start a network interface app with this command.
import: Used for the X server. Capture a screen and save image.
Install: Set attributes and copy files

J

jobs: Use this for listing jobs that are active.
Join: This one joins lines, which are on a common field.

K

kill: Stops a process from running.
Killall: Kills the processes by name.

L

less: This command displays the output on a single screen at a time.
let: This is for doing arithmetic on shell variables.
link: This command is used for creating a link to another file. 
ln: This one creates a symbolic link to another file.
local: Use this for creating variables.
locate: This one is used for finding files.
logname: This is used to print the login name being used currently.
logout: Use this command to exit a login shell.
look: When you just want to see lines that start with a particular string.
lpc: It stands for Line Printer Control.
lpr: This is for offline print.
lprint: Use this command to print a file.
lprintd: Use this to abort an ongoing print job.
lprintq: This command lists the print queue.
lprm: This removes the jobs from the print queue.

M

make: This command is used for recompiling the group of programs. 
man: This is short for manual and provides help on a command.
mkdir: Creating directories.
mkfifo: Use this to make FIFOs.
mknod: This is to create character special files or block files.
more: This displays the output, but in a single screen at a time.
mount: Used for mounting a particular filesystem.
mtools: Manipulating files from MS-DOS.
mtr: Network diagnostics command for things like ping and traceroute.
mv: Used for moving and renaming files and directories.
mmv: Mass Move and Rename

N

netstat: Get information on networking.
nice: Use this to set the priority of a job or a command.
nl: Write files and number lines.
nohup: This one runs a command, which is not affected by hangups.
notify-send: This command sends desktop notifications.
nslookup: This command is used to query internet name servers interactively.

O

open: This command opens a file in its default application.
op: Use this command for gaining operator access.

L

less: This command displays the output on a single screen at a time.
let: This is for doing arithmetic on shell variables.
link: This command is used for creating a link to another file. 
ln: This one creates a symbolic link to another file.
local: Use this for creating variables.
locate: This one is used for finding files.
logname: This is used to print the login name being used currently.
logout: Use this command to exit a login shell.
look: When you just want to see lines that start with a particular string.
lpc: It stands for Line Printer Control.
lpr: This is for offline print.
lprint: Use this command to print a file.
lprintd: Use this to abort an ongoing print job.
lprintq: This command lists the print queue.
lprm: This removes the jobs from the print queue.

M

make: This command is used for recompiling the group of programs. 
man: This is short for manual and provides help on a command.
mkdir: Creating directories.
mkfifo: Use this to make FIFOs.
mknod: This is to create character special files or block files.
more: This displays the output, but in a single screen at a time.
mount: Used for mounting a particular filesystem.
mtools: Manipulating files from MS-DOS.
mtr: Network diagnostics command for things like ping and traceroute.
mv: Used for moving and renaming files and directories.
mmv: Mass Move and Rename

N

netstat: Get information on networking.
nice: Use this to set the priority of a job or a command.
nl: Write files and number lines.
nohup: This one runs a command, which is not affected by hangups.
notify-send: This command sends desktop notifications.
nslookup: This command is used to query internet name servers interactively.

O

open: This command opens a file in its default application.
op: Use this command for gaining operator access.

P

passwd: Use this command to modify user passwords.
paste: This command is used for merging lines in files.
pathchk: It is used to check the portability of a file name.
ping: This command is used for testing network connections.
pkill: This command stops processes from running.
popd: This command restores the previous value of the directory you’re currently in.
pr: Prepare your files for printing using this.
printcap: Printer capability database
printenv: Print environment variables
printf: This command is used for formatting and printing data.
ps: This stands for Process Status.
pushd: Change the directory and save it first.
pwd: It stands for Print Working Directory.

Q

quota: This command displays the disk usage and its limits.
quotacheck: This commands lets you scan a file system to find its disk usage.
quotactl: This is used to set disk quotas.

R

ram: Ram disk device
rcp: When using two machines, this command copies files between them.
read: This commands is used for reading a line from standard input.
readarray: This commands reads from stdin into an array variable.
readonly: This command marks the variables and functions as readonly.
reboot: Self explanatory, use this command to reboot your system.
rename: Rename files
renice: This command alters the priority of the processes running. 
remsync: This command synchronises remote files through email.
return: This is used to exit from a shell function.
rev: This command reverses the lines in a file.
rm: Use this to remove particular files.
rmdir: Same as above, but for directories.
rsync: This is for synchronising file trees.

S

screen: Use this to run remote shells using ssh.
scp: This is used to create a secure copy.
sdiff: This command is used to merge two files in a secure manner.
sed: This is for the stream editor.
select: This is used when you need to accept keyboard inputs.
seq: This command is used for printing numeric sequences.
set: This command lets you manipulate shell functions and variables.
sftp: Run the secure file transfer program using this.
shift: This command is used for shifting positional parameters.
shopt: Shopt stands for Shell Options.
shutdown: Use this command when you want to shutdown Linux or restart it.
sleep: Add a delay using this command.
slocate: This is used to find particular files.
sort: Text files are sorted using this.
source: This command is used for running commands from a file.
split: This command is used to break a file into fixed sizes.
ssh: This is used to run the remote login program, that is, the secure shell client.
strace: This is used to trace signals and system calls.
su: Substitute the user identity using this command.
sudo: This is used for executing commands as a different user.
sum: File cheksums are printed using this command.
suspend: This command is used to suspend the execution of the current shell.
sync: This command is used in order to synchronise data from a disk with the memory.

T
tail: Use this command when you want to output only the last part of a file.
tar: This command is used in order to store a list or extract files in an archive.
tee: This command is used for redirecting output into multiple files.
test: This command is used for evaluating conditional expressions.
time: The running time of a program can be measured using this command.
timeout: This command is used to put a time limit on a command.
times: Use this to find the user and system times.
touch: Timestamps on a file can be changed using this.
top: This is used to get a list of the processes that are running on the system.
traceroute: Use this command to Trace Route to a host.
tr: Delete characters, translate or squeeze them.
tsort: This is used for topological sorting.
tty: This is used for printing the filename of terminal on stdin.

U

ulimit: This commands limits the user resources.
umask: This is used to determine the file permission for a new file.
umount: This command will unmount a device from the system.
unalias: This command will remove an alias.
uname: This command will print the system information.
unexpand: This command will convert the spaces in a file to tabs.
uniq: This command will uniquify your files.
units: This will convert the units from one scale to another.
unset: This command removes the variable names or the function names.
unshar: This command unpacks the shell archive scripts.
until: This command will execute a command until there is an error.
uptime: This command will show the uptime.
useradd: Use this command when you need a new user account to be created.
userdel: This command will delete an user account from your system.
usermod: Self explanatory, modify an user account.
users: This command gives you a list of users who are currently logged in.
uuencode: This command will encode binary files.

V

v: This command lists the contents of a directory.
vdir: Same as above.
vi: This is a text editor.
vmstat: This command will report on the virtual memory statistics.

W

wait: This command directs the system to wait for a process to finish.
watch: This command will display or execute a program periodically.
wc: This command prints the word, byte and line counts.
whereis: This command will search a user’s $path, source files and man pages 
which: This command searches only for a user’s $path for a program.
while: Use this to execute commands.
who: This command will print the usernames that are currently logged into the system.
whoami: This is a command that prints the current name and user id.
wget: This will retrieve the web pages or files through HTTP, HTTPS or FTP.
write: Use this to send messages to other users.

X

xargs: This command execute’s a utility and passes a constructed argument list.
xdg-open: This lets you open an URL or a file in the user's preferred application.

Y
yes: This command will print a string until it is interrupted. 
Share:

2013-11-23

ලිනක්ස් Shell Programming පාඩම-කොටස 12


    25.පයිප්ප (Pipes).

පයිප්ප කිවිවෙ වතුර යන ඒව නම් නෙවෙයි. මේවයි යන්නෙ කමාන්ඩ්. තේරුනේ නැද්ද? මෙහෙමයි අපි මේ පයිප්ප කියන ඒවයින් කරන්නෙ එක කමාන්ඩ් එකක output එක තවත් කමාන්ඩ් එකක් ඉන්පුට් එකකට ලබාදෙන එක. මේකෙ තියන විශේෂත්වය තමයි එහෙම වෙනකොට කිසිම temporary file එකක් හැදෙන්නෙ නැති වීම (මෙහෙම කියන්නෙ පළමු කමාන්ඩ් එක මගින් දෙන output එක කිසි තැනක save කරගන්නෙ නැතුව කෙලින්ම දෙවනි කමාන්ඩ් එකේ input එකට ලබාදෙන නිසා ). අපට මේක use කරන්නෙ පුලුවන් program එකක out put එක තවත් program එකක ඉන්පුට් එකට සෙට් කරවන්න ටෙම්පරි file හදන්නෙ නැතුව.


උඩ තියන පින්තුරෙන් ඒ ගැන අදහසක් ගන්න උත්සාහ කරන්න.
මේ Syntax එක use කරන්නෙ මේ විදියට.
Command 1 | Command 2

මෙන්න මේ උදාහරණ බැලුවහම හරියටම තේරුම් ගන්න පුලුවන් වේවි.

      1. ls | more –
        ls කමාන්ඩ් එකෙන් වෙන දේ දන්නවනෙ. more කියන කමාන්ඩ් එකත් එක්ක combine කරහම වෙන්නෙ මෙහෙම වැඩක් අපි හිතමු අපි files හා folders ගොඩක් තියන directory එකක ඉදන් ls type කරා කියල එතකොට මෙන්න මේවගේ result එකක් තමයි ටර්මිනල් එකේ Display වෙන්නෙ.


අපි ls | more කියන විදියට රන් කරොත් මෙන්න මේවගේ result එකක් තමයි ලැබෙන්නෙ.කමාන්ඩ් දෙකක එකතුවකින් තමයි මේ result එක ලැබුනෙ.

පෙන්නන තියන දේවල් ලිස්ට් එකක් විදියට පෙන්නනන එක තමයි විශේෂත්වය. එහෙම පෙන්නන්න Screen එක මදිනම් --More-- කියන එක උඩ enter button එක එබීමෙන් ඊළඟ ටික බලන්න පුලුවන්.

2. who | sort 
who කියන කමාන්ඩ් එකෙන් ලැබෙන්නෙ user Account ප්‍රමාණය. Sort කියන කමාන්ඩ් එකත් කලින් use කරල තියෙනව ඒකෙන් වෙන්නෙ අනුපිළිවෙලකට සැකසෙන එක.මේ කමාන්ඩ් එක රන් කිරීමෙන් sort උන user Account ප්‍රමාණය බලා ගන්න පුලුවන්.


3.who | sort > user_list
කලින් කමාන්ඩ් එක මගින් උන දේම තමයි සිද්ධවෙන්නෙ. හැබැයි output එක write වෙන්නෙ ඔයා දැනට ඉන්න ඩිරෙක්ටරි එකේ user_list කියල හැදෙන file එකේ.( > ,>> ,< මේව මතකයිනෙ redirection වලදි කරේ )

4. who | wc -l 
wc කියන කමාන්ඩ් එකෙන් යමක lines ප්‍රමාණය,වචන,අකුරු වගේ ඒවගෙ count එකක් ගන්න පුලුවන්.භාවිතා කරන හැටි පහල තියන ඒව් මගින් ඉගෙන ගන්න.
wc -c :-මේකෙන් bytes වල එකතුව ගන්න පුලුවන්
wc -m :-අකුරු වල එකතුවක් ලබා ගන්න පුලුවන්.
wc -C :- wc -m වලින් ලැබුන ප්‍රතිඑලයම තමයි.
wc -l : lines වල එකතුව.
wc -w : අකුරු අතර තියන හිස් අවකාශය(white space) count කරනව.

who | wc -lවලින් පෙන්නන්නෙ ලයින් ප්‍රමාණෙ count එකusers 5ක් හිටියොත් රිසල්ට එක 5 කියල පෙන්නනෙ. ඔයාලගෙ ඉන්න users ප්‍රමාණයෙ එකතුවක් දකින්න ලැබෙයි.

  1. ls -l | wc -l
මේක ඔයාල කරල බලලම තේරුම් ගන්න හැම එකම කියල දෙන එක හොඳ නෑ නෙ.



Share:

2013-10-12

ලිනක්ස් Shell Programming පාඩම-කොටස 11






  1. ඇයි මේ Command Line arguments අවශ්‍ය වෙන්නෙ.
ප්‍රධාන කාරණා දෙකක් තියෙනව.
      1. කමාන්ඩ් එකට අවශ්‍ය option එකක් ලබා දීමට.
        echo -e “mad”
        මේකෙ මේ -e කියල තියෙන්නෙ පළමු argument එක ඒක echo කියන command එකේ option එක.
      2. කමාන්ඩ් එකට මොන files reading and writing කරන්න ඕන කියල ලබා දෙන එක.
        rm කියන කමාන්ඩ් එකෙන් පුලුවන් file එකක් remove කරන්න ඒ කිව්වෙ delete කරන්න ඉතින් එහෙම කරන්න මොන file එකද අයින් කරන්න ඔන කියල කමාන්ඩ් එකට දෙන්න ඔන. ඒක කරන්නෙ මෙහෙමයි.
rm file එකේ නම
rm filename
ඊළඟට බලමු කොහොමද command line arguments අපේ shell ස්ක්‍රිප්ට් එකට pass කරන්නෙ කියල.
අපි හදපු my.shell කියල ශෙල් script එකක් තියනව කියල හිතමු. දැන් ටර්මිනල් එකෙන් ඒක රන් කරමු 24 කියන argument එකත් pass කරගෙන.
./my.shell 24
මේවගේ අපට කැමති arguments ගණනක් pass කරන්න පුලුවන්.ඊළඟට බලමු කොහොමද අපි ටර්මිනල් එකෙන් පාස් කරපු arguments ශෙල් එක ඇතුලෙදි අල්ල ගන්නෙ කියල.අපි හිතමු අපි අපි argument තුනක් පාස් කරා කියල ඒ තුන අපට $1 , S2 , $3 කියල හදා ගනිපු වේරියබල් තුනකින් ඒ පාස් කරපුව අල්ල ගන්න පුලුවන්. සරලවම කිව්වෙත් $1 කියල හදපු වේරියබල් එකට පළමු argument එකත් $2 ට දෙවනි argument එකත් S3 ට තුන්වෙනි argument එකත් assign වෙනව.තවමත් පැහැදිලි නැත්තම් මේ උදාහරණය බලන්න.


අපි මුලින්ම හදාගනමු my.shell කියල script එකක් ඒකෙ මෙන්න මෙහෙම ටයිප් කරල save කරගන්න.
#########################################

# gedit my
#!/bin/bash
# Catch arguments
# sh scriptname 1 2 3

echo "My 1st Argument is : $1"
echo "My 2nd Argument is : $2"
echo "My 3rd Argument is : $3"
#########################################

දැන් ටර්මිනල් එකේ මේක රන් කරනකොට මෙන්න මේ විදියට argument තුනකුත් එක්ක රන් කරන්න.
./my.sh 5 9 4
resutl එක මෙන්න මේ විදියට පෙනේවි.

My 1st Argument is : 5
My 2nd Argument is : 9
My 3rd Argument is : 4 
 
අපි පාස් කරපු එක shell එක ඇතුලෙදි අල්ලගෙන ප්‍රින්ට් කරපු එක තමයි මෙතනදි සිද්ද උනෙ.තව වැදගත් වෙන දේවල් කිහිපයක් බලමු ඊළඟට
01. $0 කියන වේරියබල් එකක් හැදුවොත් ඒකට assign වෙනව shell එකේ නම.

02.$* හරි $@ කියන ඒවයින් ටර්මිනල් එකෙන් එවන argument ඔක්කෙම එක පාරට අල්ල ගන්න පුලුවන්.

මේ උදාහරන කරල බලන්න ඒවයින් තේරුම් ගන්න පුලුවන් ලේසියෙන්ම.

Arguments කැමති ගානකුත් එක්ක මේක රන් කරන්න.

#########################################

# gedit my
#!/bin/bash
# Catch arguments
#
echo "My Arguments are : $@"
#########################################



Arguments තුනක් එක්ක මේක රන් කරන්න.

#########################################

# gedit my
#!/bin/bash
# Catch arguments
#
echo "My Argument name is : $0"
echo "My Arguments are : $1"
echo "My Arguments are : $2"
echo "My Arguments are : $3"
#########################################

තව මතක තියා ගන්න ඕන කරුණක් තමයි $0,$2,$3 කියල අර්ගියුමන්ට් අල්ල ගන්න වේරියබල් අපට script එක ඇතුලෙ ආයෙ භාවිතා කරන්න බැරි බව.

24 .Redirection (ප්‍රතිදිශාව). 

 
මේ කතන්දරෙන් කියන එකත් ඒ තරම් අමාරු දෙයක් නෙවෙයි අපි බලමු දැන් ඒ ගැන. අපි සාමාන්‍යයෙන් මොකක් හරි කමාන්ඩ් එකක් රන් කරපුවහම ඒකෙ ප්‍රතිඑලය ටර්මිනල් එකේ ප්‍රින්ට් වෙන එකනෙ වෙන්නෙ. හොඳම උදාහරණෙ තමයි ls කමාන්ඩ් එක එක ටයිප් කරහම ඔයලට ටර්මිනල් එකේම අදාල out put එක පෙන්නන එක. අපට පුලුවන් ඔන්න ඔය දෙන out put එක අපි හදාගනිපු file එකකට අරගන්න, එහෙමත නැත්තම් file එකක් read කරල එකෙ තියන ඒව අරගෙන ටර්මිනල් එකට ලබා ගන්න. ඔන්න ඔය කතාවට තමයි redirection කියල කියන්නෙ.
ඔන්න බලන්න එක කරන හැටි.මුලින්ම ඔය දැන් ඉන්න directory එකේ man.txt කියල text file එකක් හදාගන්න. ඊළඟට ටර්මිනල් එකේ මෙහෙම ටයිප් කරල එන්ටර් ඔබන්න . (ටර්මිනල් එකෙනුත් ඒ directory එක ඇතුලෙ ඉන්න ඔන. )

ls > man.txt


දැන් ඔයාල man.txt කියන file එක ඔප්න් කරල බැලුවෙත් ඔයාලට පෙනෙයි ls මගින් ටර්මිනල් එකේ ටයිප් වෙන්න ඕන ටික man.txt කියන file එකේ save වෙලා තියෙන බව.

ලේසි ක්‍රමේ : - කලින් කරා වගේ මුලින් man.txt කියන file එක හදල ඉන්න ඔන නෑ. ඔය ls > man.txt කියන කමාන්ඩ් එක නිකම්ම ටර්මිනල් එකේ ටයිප් කරහම man.txt එක ඔටෝ හැදිල ඒකෙ ls මගින් අවශ්‍ය දේවල් ටික ලියවෙනව.

ප්‍රධාන Redirection සලකුණු (symbols) තුනක් තියෙනව.ඒව තමයි

      1. >
      2. >>
      3. <
        අපි දැන් බලමු ඒවයි තියෙන වැඩ කිඩ ටික.

          1. > - මේක ඔයාල කරල බැලුවනෙ. මේ ලකුණ යොදා ගත්තම හැම තිස්සෙම write කරන්න ඔන file එක අලුතෙන්ම හැදෙනව. කලින් එහෙම file එකක් තියෙනම් කිසිම කතාවක් නැතුව ඒක overwrite වෙනව.කරලම බලන්නකො.

          2. >> - මෙන්න මේවිදියට තමයි මේක භාවිතා කරන්නෙ.

            ls >> fileName

            මේකෙ තියන විශේෂත්වෙ තමයි කලින් එකේ වගේ overwrite වෙන්නෙ නැතුව එකම file එක write වෙන එක. ඒ කිව්වෙ මෙහෙමයි අපි හිතමු අපි write කරන්න ඉන්න file එක ඇතුලෙ කලින් save කරපු තව මොනව හරි දේවල් තියෙනව කියල ඒව වෙනස් නොවී ඒවට යටින් අලුත් දේවල් ටික save වෙන එක.ඉතින් මේකෙන් පුලුවන් කලින් දේවලුත් එක්ක අලුත් දේවලුත් තියා ගන්න.

          3. < - මේකෙන් තමයි file එකක තියෙනෙ ඒව read කරන වැඩේ කරන්නෙ.
            එක කරන්න පුලුවන් මෙහෙම. මුලින්ම හදන්න මොනව හරි ටයිප් කරපු දේවල් තියෙන ටෙක්ස්ට් file එකක් ඒකෙ නම දෙන්න my.txt කියල දැන් ටර්මිනල් එකෙන් එක තියන directory එකට ගිහින් මෙන්න මෙහෙම ටයිප් කරල රන් කරන්න.

            cat < my.txt
cat කියන කමාන්ඩ් එකෙන් file දෙකක් මූට්ටු කරන්නයි එව ඇතුලෙ තියන ඒව ප්‍රින්ට කරන්නයි පුලුවන්.
මෙව්ව ගැන වැඩි විස්තර පස්සෙ පස්සෙ දැන ගන්න පුලුවන්.
දැන් මේවයින් පොඩි උදාහරණයක් බලමු.
ටර්මිනල් එක ඔපන් කරල මෙන්න මේ කමාන්ඩ් එක රන් කරන්න.

cat > myfile.txt

එතකොට කර්සර් එක බිලින්ක් වෙවී තියෙනව එතකොට ඔයාල ඔය පහල තියෙන පින්තුරෙ වගේ ඔය නගර වල නම් ටික එන්ටර් කරල ඉවරවෙලා CTRL + D ඔබල save කරන්න.



 දැන් ඔය ඉන්න directory එකේ ඒ නගර ටික save උන myfile.txt කියල file එකක් හැදිල ඇති. අපට ඔන ඒ file එකේ තියන නගර වල නම් alphabet එකේ පිලිවෙළට හදන්න. ඒකට කරන්නෙ මෙන්න මේ වැඩේ.මෙන්න මේ කමාන්ඩ් එක රන් කරන්න.

sort < myfile.txt > sorted
ඊළඟට මේක රන් කරන්න
cat sorted
එතකොට sort උන පිලිවෙලට ප්‍රතිඑලය දැකගන්න පුලුවන්. තවත් එකක් තමයි sorted කියල file එකකුත් හැදිල තියෙන බව දකින්න පුලුවන් අදාල directory එකේ .ඒකෙ තමයි sort උන ලිස්ට් එක සේව් වෙලා තියෙන්නෙ.

තියෙන කමාන්ඩ් එක රන් කරහම වෙන්නෙ myfile.txt එකේ තියෙන ඒව read කරල sort කරල sorted කියන නමින් file එකක් හදල ඒකට සේව් කරන එක.
sort -කියන කමාන්ඩ් එක නිතරම අනුපිලිවෙලට සකසන දේවල් වලට භාවිතා කරන්න පුලුවන්.

 

Share: