0
Introduction
Linux is becoming more and more prominent in the networking industry. Many of us come from a mixed background and have varying levels of knowledge of Linux. I’ve been around Linux for a long time but really never got beyond the very most basic stuff. Looking back, I wish I had spent some more time learning Sed, Awk, regex, and Bash etc. I was doing some labs over at NRE Labs (great labs), and wanted to highlight some of the things I learned.
Appending To a File With Cat
Sometimes you want to append something quickly to a file or send several lines of text to a Linux command. That can be done using “here documents“.
First, look at this small configuration:
daniel@devasc:~/DevAsc$ cat config.txt
interface GigabitEthernet0/1
switchport mode access
switchport access vlan 10
!
interface GigabitEthernet0/2
switchport mode access
switchport access vlan 10
!
interface GigabitEthernet0/3
switchport mode access
switchport access vlan 10
!
Now we want to append another interface to the end of this file. We can do that using cat:
daniel@devasc:~/DevAsc$ cat <<EOT >> config.txt
> interface GigabitEthernet0/4
> switchport mode access
> switchport access vlan 10
> !
> EOT
After the cat command, Continue reading