hi..i wanted to know is there any way to take input from the user and copy that a particular line number in a particular file
for eg . i wanted to create acl in squid at line number 2400 in squid.conf file
so the user gives an input like acl inetblock src 192.168.0.0/255.255.0.0
so is there any way i can append this line to line number 2400
will i have to use awk or sed or regex ..i dont know what to use ..
i am a noob in linux so was looking for help
Play around with something like:
#!bin/sh
read -p "Give your input: " resp
awk -v var=$resp 'NR==2400{print var}{print}' file > new_file
Regards
i named the script squid.sh and this is what the output was
[userX@server1 ~]# ./squid.sh
Give your input: acl squid test dstdomain yahoo.com
awk: cmd. line:1: fatal: cannot open file `test' for reading (No such file or directory)
i couldnt understand what the error was here ...
Quote the variable:
awk -v var="$resp" 'NR==2400{print var}{print}' file > new_file
Regards