Skip to content

Instantly share code, notes, and snippets.

@byJeevan
Created December 18, 2018 13:00
Show Gist options
  • Save byJeevan/c41efbc0eeeb5c722160cecda83b4ef7 to your computer and use it in GitHub Desktop.
Save byJeevan/c41efbc0eeeb5c722160cecda83b4ef7 to your computer and use it in GitHub Desktop.
This gist contains the collection of shell scripts for reference
#!/bin/sh
#*****Reading ******#
#From user
read -p "Enter Name: " userName
echo $userName
#From text file - line by line
while read line; do
echo $line
done < en.txt
#Convert string (by split with ;) to array
csvStr="a,b,c"
IFS=',' read -ra itemArray <<< "$csvStr"
#***** PRINTING ****#
#Print first item in the array
echo "FIRST ITEM -- > ${itemArray[0]}"
#Print all items from array
for i in "${itemArray[@]}"; do
echo $i
done
#
echo "Completed !!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment