KEMBAR78
Shell Commands | PDF | Computing | Software
0% found this document useful (0 votes)
25 views3 pages

Shell Commands

The document details a series of commands executed in a bash training session, including attempts to run and debug two scripts: 'arraybash.sh' and 'functionposarg.sh'. The user encounters various syntax errors and issues related to executing scripts and using commands like awk and sed. Ultimately, the user successfully runs the scripts and manipulates text files with awk and sed commands.

Uploaded by

ram14linga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Shell Commands

The document details a series of commands executed in a bash training session, including attempts to run and debug two scripts: 'arraybash.sh' and 'functionposarg.sh'. The user encounters various syntax errors and issues related to executing scripts and using commands like awk and sed. Ultimately, the user successfully runs the scripts and manipulates text files with awk and sed commands.

Uploaded by

ram14linga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.

sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ chmod u+x arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
bash: ./arraybash.sh: cannot execute: required file not found
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
./arraybash.sh: line 4: syntax error near unexpected token `('
./arraybash.sh: line 4: `MY_FIRST_ARRAY= (one , two , three, four)'
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
./arraybash.sh: line 4: syntax error near unexpected token `('
./arraybash.sh: line 4: `MY_FIRST_ARRAY= (one two three four)'
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
one
full array.................
one two three four
getting third value
three
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
one
full array.................
one two three four
getting third value
three
hmmmm working fine move on to next item!!!
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
one
full array.................
one two three four
getting third value
three
hmmmm working fine move on to next item!!!
./arraybash.sh: line 18: syntax error near unexpected token `done'
./arraybash.sh: line 18: `for item in ${MY_FIRST_ARRAY[@]}; done echo -n $item | wc
-c; done'
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./arraybash.sh
one
full array.................
one two three four
getting third value
three
hmmmm moving to for loop from this array list!!!
3
3
5
4
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ chmod u+x functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
bash: ./functionposarg.sh: /bin/bash/: bad interpreter: Not a directory
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ chmod u+x functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
bash: ./functionposarg.sh: /bin/bash/: bad interpreter: Not a directory
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$
ram@ram-IdeaPad-5-15IAL7:~/bash-training$
ram@ram-IdeaPad-5-15IAL7:~/bash-training$
ram@ram-IdeaPad-5-15IAL7:~/bash-training$
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim arraybash.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
hello rama
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
hello
./functionposarg.sh: line 5: []: command not found
./functionposarg.sh: line 14: syntax error near unexpected token `then'
./functionposarg.sh: line 14: `if[$? = 1]; then'
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
./functionposarg.sh: line 5: [rama]: command not found
./functionposarg.sh: line 14: syntax error near unexpected token `then'
./functionposarg.sh: line 14: `if[$? = 1]; then'
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
./functionposarg.sh: line 5: [rama: command not found
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
./functionposarg.sh: line 5: [rama: command not found
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh tet
hello tet
./functionposarg.sh: line 5: [tet: command not found
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
hello
./functionposarg.sh: line 5: [: missing `]'
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh
hello
./functionposarg.sh: line 5: [: missing `]'
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
./functionposarg.sh: line 5: [rama: command not found
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh tinku
hello tinku
some unauthorized person accessd the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh tinku
hello tinku
some unauthorized person accessed the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
hello rama you are rocking
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
hello rama you are rocking
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh Rama
hello Rama
some unauthorized person accessed the page
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh Rama
hello Rama
hello Rama you are rocking
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh Rama
hello Rama
hello Rama you are rocking
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ ./functionposarg.sh rama
hello rama
hello rama you are rocking
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim functionposarg.sh
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ echo one two three four five >
awktestfile
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ awk '$1' awktestfile
one two three four five
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ awk 'print $1' awktestfile
awk: line 1: syntax error at or near print
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ awk '{print $1}' awktestfile
one
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim awkcsv.csv
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ awk -F, '{print $2}' awkcsv.csv
two
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ echo "hello todau i ate biriyani that is
awesome" | awk '{print $3}'
i
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ echo "hello todau i ate biriyani that is:
awesome" | awk -F: '{print $2}' | cut -c2
a
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ echo "hello todau i ate biriyani that is:
awesome" | awk -F: '{print $2}' | cut -c3
w
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ echo "hello todau i ate biriyani that is:
awesome" | awk -F: '{print $2}' | cut -c5
s
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim sedtest.txt
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ sed 's/fly/grasshopper/g' sedtest.txt
the grasshopper flies like no grasshopper files
the grasshopper is a insect that has no wings and the grasshopper likes to eat left
over..
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim sedtest.txt
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ sed -i.ORIGINAL 's/fly/grasshopper/g'
sedtest.txt
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim sedtest.txt.ORIGINAL
ram@ram-IdeaPad-5-15IAL7:~/bash-training$ vim sedtest.txt
ram@ram-IdeaPad-5-15IAL7:~/bash-training$

You might also like