I am trying to use the output of a cut command into a head command to output a specific line. I find that if the number being fed into the head command 10+ it works fine. So I am wondering if the cut -c1-2 is including white space for the single digits that is tripping up the head command?
my code
#!/bin/bash
echo "Enter your name"
read input
cut -c5-19 filelist | grep -n "$input" | cut -c1-2 > cat
while read cat
do
head -$cat filelist | tail -1 > filelist2
done < cat
Any advice or suggestions will be greatly appreciated! Thank you :) Edit
FULLRanjit Singh Marketing Eagles Dean Johnson
FULLKen Whillans Marketing Eagles Karen Thompson
PARTPeter RobertsonSales Golden TigersRich Gardener
CONTSandeep Jain President Wimps Ken Whillans
PARTJohn Thompson Operations Hawks Cher
CONTCher Operations Vegans Karen Patel
FULLJohn Jacobs Sales Hawks Davinder Singh
FULLDean Johnson Finance Vegans Sandeep Jain
PARTKaren Thompson EngineeringVegans John Thompson
FULLRich Gardener IT Golden TigersPeter Robertson
FULLKaren Patel IT Wimps Ranjit Singh
This is 'filelist' The error I am getting is "head: invalid trailing option -- :" If I type in 'Patel' as the name, it works.