<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[File Test Operators(bash script use කරල file එකක් හදල permission දීල run කරමු)]]></title><description><![CDATA[<p dir="auto">හරි මම ඔයාලට කියල දෙන්නෙ මේ වෙනකන් කියල දීපු හැම පොස්ට් එකකින්ම ගත්ත දේවල් එකතු කරල කොහොමද linux වලදි එක ස්ක්‍රිප්ට් එකකින් ෆයිල් එකක් හදල ඒක ඇතුලෙ දෙයක් type කරල ඒකට execute permission දීලා ඒක run කරන්නෙ කියලා.</p>
<p dir="auto">හරි දැන් ඔයාල මෙන්න මේ වගේ sh file එකක් හදාගෙන script එක ලියන්න.</p>
<pre><code>#!/bin/bash

cd ~ #මේ කියන්නෙ ඔයා ඉන්න directory එකෙන් ඊට කලින් තිබ්බ directory එකට යන්න කියල  මම මේ ඉන්නෙ Documents Directory එකේ තියෙන folder එකක ඒ නිසා මම මගේ User Directory එකට යන්න දෙපාරක් back වෙන්න ඕන  
cd ~ # මේ දෙවනි එක 

cd Desktop# හරි මම දැන් ඔන්න Script එකේ ලියනවා Desktop Directory එකට එන්න කියල 

if [ -d new ] #මේ කියන්නේ new කියල Directory එකක් තියෙනවද කියල බලන්න කියන එක 
then
	echo "Directory available" #එහෙම තියෙනවනම් Directory available කියල display කරන්න
	cd new #තියෙනවනම් ඒක ඇතුලට යන්න 
else 
	echo "Directory not available so i am creating file.."#එහෙම නැත්නම්not  Directory available කියල display කරන්න
	mkdir new#Directory එක හදන්න
	cd new#දැන් ඒක ඇතුලට යන්න
fi #එක decision making command set එකක් ඉවරයි

if [ -f foo.sh ] #හරි දැන් බලන්න foo.sh කියල file එකක් තියෙනවාද කියල 
then 
	echo "File available"#එහෙම තියෙනවානම් File available කියල print කරන්න 
else
	echo "File not available so i am creating file..." #එහෙම නැත්නම් File not available so i am creating file..." කියල print කරලා
	touch "foo.sh"; echo "#!/bin/bash" &gt;&gt; foo.sh #File එක හදන්න හදලා ඒකෙ #!/bin/bash කියල type කරන්න කියන්න 
fi

if [ -e foo.sh ] #හරි මේ බලන්නෙ ඒ හදපු ෆයිල් එක ඇතුලෙ text මොනවා හරි තියෙනවාද කියල
then 
	echo "available"# එහෙම තියෙනවානම් available කියල print කරන්න 
else
	echo "Not available so i am writing.." #එහෙම නැත්නම් 
	echo "#!/bin/bash" &gt;&gt; foo.sh##!/bin/bash කියල ෆයිල් එක ඇතුලෙ ටයිප් කරන්න 
fi

if [ -x foo.sh ]#මේ කියන්නෙ ඒ හදපු ෆයිල් එකට execution permission දීලද බල්න්න කියල 
then
	echo "Yes executable file so i am opening file"#එහෙම දීලනම්
	open foo.sh#open කරන්න 
	./foo.sh#Execute කරන්න 
else
	echo "Not a executable file i give permission and opening file"#file එකට permission දීල නැත්නම් 
	chmod +x foo.sh #permission දෙන්න 
	open foo.sh
	./foo.sh
fi

echo "enter yes if you want edit file otherwise enter no" # හරි මම දැන් කියනවා ඔයාට ඒ file එක ආයිත් edit කරන්න ඕනනම් yes කියල type කරන්න එපානම් No කියල ටයිප් කරන්න 
read input #user ගේ input එක ගන්න 

if [ "$input" = "yes" ] # input එක yes නම් 
then
	open foo.sh # ෆයිල් එක open කරන්න 
else 
	echo "Work done bye!!!!" 
fi

</code></pre>
<p dir="auto">:alien:</p>
<p dir="auto"><img src="/assets/uploads/files/1570411211036-screen-shot-2019-10-07-at-6.50.04-am-resized.png" alt="0_1570411209941_Screen Shot 2019-10-07 at 6.50.04 AM.png" class=" img-responsive img-markdown" /></p>
]]></description><link>https://lankadevelopers.lk/topic/403/file-test-operators-bash-script-use-කරල-file-එකක-හදල-permission-ද-ල-run-කරම</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 01:56:02 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/403.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Oct 2019 01:21:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to File Test Operators(bash script use කරල file එකක් හදල permission දීල run කරමු) on Mon, 07 Oct 2019 17:12:04 GMT]]></title><description><![CDATA[<p dir="auto">eka patta mchan</p>
]]></description><link>https://lankadevelopers.lk/post/2347</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2347</guid><dc:creator><![CDATA[Nubelle]]></dc:creator><pubDate>Mon, 07 Oct 2019 17:12:04 GMT</pubDate></item></channel></rss>