How to use a variable in sed for adding the text into the file?
Code:
if [ -x /usr/bin/ifconfig ] || [ -x /sbin/ifconfig ] ; then Now how do I use that to add it into the file? It keeps just adding the word $NIC in the file and not its value Code:
net_get_bytes_inout(const char *device, double *in_bytes, double *out_bytes) |
I'm probably missing something, but wouldn't
Code:
echo $NIC >> epplets/net.c Was there some specific reason you wanted to use sed? |
Quote:
Quote:
Code:
awk -v x="$NIC" 'NR==100{print x} 1' epplets/net.c > tmp && mv tmp epplets/net.c thanks for your inquiry. |
Code:
sed -i "100i$NIC" epplets/net.c You could use the backslash form if you really wanted, but I wouldn't recommend it in a script. Read the doco more closely for whay. |
Quote:
Code:
userx@SlackOLatern.net:/media/projects/git-eterm/e16-epplets-0.16/epplets Code:
unsigned char |
Arggghh - I always use GNU sed. :doh:
|
Quote:
it's Linux, one would then think it is GNU.. hummm, let me look. Code:
$ sed --version |
Quote:
Code:
sed -i "100i\\$NIC" epplets/net.c |
All times are GMT -5. The time now is 06:31 AM. |