Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
shell scripting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kyle Muldoon
shell scripting
Commits
4ea139b4
Commit
4ea139b4
authored
4 years ago
by
Kyle Muldoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uploaded script files
parent
4de5f109
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
Q1.sh
Q1.sh
+20
-0
Q2.sh
Q2.sh
+12
-0
Q3.sh
Q3.sh
+7
-0
Q4.sh
Q4.sh
+10
-0
No files found.
Q1.sh
View file @
4ea139b4
# !/bin/bash
# sample.txt:
# 1,Apple,Color is Red
# 2,Mango,Color is Orange
# 3,Banana,Color is Yellow
input
=
"../input/sample.txt"
tableName
=
"myfruits"
lineFormat
=
"(code,name,color)"
while
read
-r
line
;
do
code
=
$(
echo
$line
|
awk
-F
,
'{print $1}'
)
name
=
$(
echo
$line
|
awk
-F
,
'{print $2}'
)
color
=
$(
echo
$line
|
awk
-F
,
'{print $3}'
)
echo
"insert into
${
tableName
}
${
lineFormat
}
values (
${
code
}
,
\"
${
name
}
\"
,
\"
${
color
}
\"
)"
done
<
"
$input
"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Q2.sh
View file @
4ea139b4
# !/bin/bash
# Ensure non-null input to program
if
[
"$#"
-ne
1
]
;
then
echo
"Error: Missing Argument"
exit
1
fi
# # Collect input from args
input
=
$1
awk
-F
:
'$5 == input {print "Home Directory: "$7}'
/etc/passwd
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Q3.sh
View file @
4ea139b4
#!/bin/bash
# Convert any string given as an argument to upper case
for
var
in
"
$@
"
do
echo
"
${
var
^^
}
"
done
This diff is collapsed.
Click to expand it.
Q4.sh
View file @
4ea139b4
#!/bin/bash
# Iterate from 1 to 50, printing the odds
for
i
in
{
1..50
}
do
if
((
$i
% 2
==
1
))
;
then
echo
"Number is :
${
i
}
"
fi
done
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment