I'm making a script to preform "dig ns google.com" and cut off the all of the result except for the answers section.
So far I have:
#!/bin/bash echo -n "Please enter the domain: " read d echo "You entered: $d" dr="$(dig ns $d)" sr="$(sed -i 1,10d $dr)" tr="$(head -n -6 $sr)" echo "$tr"
Theoretically, this should work. The sed and head commands work individually outside of the script to cut off the first 10 and last 6 respectively, but when I put them inside my script sed comes back with an error and it looks like it's trying to read the variable as part of the command rather than the input. The error is:
sed: invalid option -- '>'
So far I haven't been able to find a way for it to read the variable as input. I've tried surrounding it in "" and '' but that doesn't work. I'm new to this whole bash scripting thing obviously, any help would be great!