I'm trying to number list a certain section of the file but I'm not managing.
I want the IP section to be numbered only
Here is what I want to have:
[Output of what I would like][1]
Here is what I get:
[Output of what I get][2]
- echo "Number Server" echo "-------- --------" nl server.list.txt echo -n "Enter the server number to delete: " select read select if [[ $select -eq 3 ]] then sed -i '3d' server.list.txt #deletes the 3rd line elif [[ $select -eq 4 ]] then sed -i '4d' server.list.txt #deletes the 4th line elif [[ $select -eq 5 ]] then sed -i '5d' server.list.txt #deletes the 5th line else echo "" echo "ERROR: The number entered is invalid !!!" echo "" fi;;
CodePudding user response:
Use sed
to print the first two lines with spaces at the beginning.
Then use tail
to pipe the rest of the file to nl
.
sed -n '1,2s/^/ /' server.list.txt
tail -n 3 server.list.txt | nl