summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Yankov <golergka@gmail.com>2013-08-18 14:25:20 +0200
committerMax Yankov <golergka@gmail.com>2013-08-18 15:03:43 +0200
commit3e8c292a10eabd9816f7b0ccb9249661fbb4c3be (patch)
tree9381eec71198b2a025654b16a3018f79a966ba4c
parenta538c52fb444fc14782ceb8353f69da04d232e60 (diff)
Bash: commands, attributes, ls, grep & pipe
-rw-r--r--bash.html.markdown13
1 files changed, 12 insertions, 1 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 4e1eff9e..8cf7be18 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -44,12 +44,23 @@ if true
then
echo "This is expected"
else
- echo "And is was not"
+ echo "And this is not"
fi
# Expressions are denoted with the following format:
echo $(( 10 + 5 ))
+# Unlike other programming languages, bash is a shell — so it works in a context of current directory.
+# You can list files and directories in the current directories with ls command:
+ls
+
+# These commands have options that control their execution:
+ls -l # Lists every file and directory on a separate line
+
+# Results of the previous command can be passed to the next command as input.
+# grep command filters the input with provided patterns. That's how we can list txt files in the current directory:
+ls -l | grep "\.txt"
+
# Commands can be substitued within other commands using $( ):
# The following command displays the number of files and directories in the current directory.
echo "There are $(ls | wc -l) items here."