I'm trying to create a shell script in Linux to accept only 2 arguments for the date and one for the time (while at the same time accepting am/pm)
Here's one of the scripts I attempted to write up.
#!/bin/bash
date=$1
space=" "
time=$2
ampm=$3
timeampm=$2$space$3
print("date $1")
print("time $2")
print("ampm $3")
print("timeampm $timeampm")
Heres the file I'm going off
0310 02:00:00 AM Abigale Rich
0310 05:00:00 AM Billy Jones
0310 08:00:00 AM Billy Jones
0310 11:00:00 AM Summer-Louise Hammond
0310 02:00:00 PM Billy Jones
0310 05:00:00 PM Rahima Figueroa
0310 08:00:00 PM Billy Jones
0310 11:00:00 PM Billy Jones
0312 02:00:00 AM Abigale Rich
0312 05:00:00 AM Billy Jones
0312 08:00:00 AM Billy Jones
0312 11:00:00 AM Summer-Louise Hammond
0312 02:00:00 PM Billy Jones
0312 05:00:00 PM Rahima Figueroa
0312 08:00:00 PM Billy Jones
0312 11:00:00 PM Billy Jones
0315 02:00:00 AM Abigale Rich
0315 05:00:00 AM Billy Jones
0315 08:00:00 AM Billy Jones
0315 02:00:00 PM Billy Jones
0315 05:00:00 PM Rahima Figueroa
0315 08:00:00 PM Billy Jones
For example, on line 3, I want to be able to ./scriptname.sh 0310 08:00:00 AM and it pulls out the name "Billy Jones"
I have been mostly trying to use grep, awk and sed. If you want to see my other codes I've written up, I'll add them.