$ cat file.txt | grep -v "#" | grep -v "^$"
cat packages.txt | xargs sudo apt-get install -y
Find and replace text within a file using sed
The procedure to change the text in files under Linux/Unix using sed:
- Use Stream EDitor (sed) as follows:
- sed -i 's/old-text/new-text/g' input.txt
- The s is the substitute command of sed for find and replace
- It tells sed to find all occurrences of ‘old-text’ and replace with ‘new-text’ in a file named input.txt
- Verify that file has been updated:
- more input.txt
RHEL, Fedora, and CentOS based distributions
We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
Then update the package cache and install the package using dnf (Fedora 22 and above):
sudo dnf check-update
sudo dnf install code
Or on older versions using yum:
sudo yum install code
Due to the manual signing process and the system we use to publish, the yum repo may lag behind and not get the latest version of VS Code immediately
It’s the section that the man page for the command is assigned to.
# man 1 man
# man 3 find
# man -s 1 man
depending on your OS
—— part 1 ——-
1) get list of disks
# fdisk -l
2) Find disk in list, /dev/???
in this example /dev/sda
3) run fdisk again and specify disk
# fdisk /dev/sda
4) print current partiions
Command (m for help): p
5) use the d command to delete any of the existing partitiond
Command (m for help): d
you may have to run this multiple times if there is more that 1 partition.
6) print current partiion list again, to make sure its empty
Command (m for help): p
7) Use the o command to create a new DOS partition table
Command (m for help): o
8) use the n command to create a new partition
Command (m for help): n
accept all defaults
9) use the t command to change the partition type
Command (m for help): t
use the hex code b to select W95 FAT 32
10) use the w command to write changes to disk.
Command (m for help): w
—– part 2 ———-
mkfs -t vfat /dev/sda1
See man pages fstab(5) and mount(8).
Using the nofail mount option will ignore missing drives during boot.
nofail Do not report errors for this device if it does not exist.
So your fstab line should instead look like:
UUID=6826692e-79f4-4423-8467-cef4d5e840c5 /backup/external ext4 defaults,nofail 0 0
Notes on how to create or add disk, volume groups and logical volume in Linux (RedHat)
1. First add disk to system by what ever means your system requires.
2. Find name of disk using fdisk
# fdisk -l /dev/sd* | grep i 'Disk'
For my examples below, it would have listed sdb but not had any partition data with it.
3. Create a new partition on the disk using fdisk
# fdisk /dev/sdb
n to create a new partition
p for primary
enter through the other options
w to write the config and exit
3. make sure the disk and partition are setup OK by using lslbk
4. create the physical volume (pv) on the new disk (sdb1)
# pvcreate /dev/sdb1
5. list current volume groups
6a. to create a new volume group, use vgcreate with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgcreate vg_oracle /dev/sdb
6b. extend the current volume group to include the new physical volume use vgextend with the volume group name (vg_oracle) and the disk device (/dev/sdb1)
# vgextend vg_oracle /dev/sdb1
7a. to create a new volume group
# lvcreate -L 20G -n lv_u01 vg_oracle
7b. to extend the logical volume
to increase it by 100GB
# lvextend -L +100G /dev/mapper/vg01_data-lv_data
to increase it to use 25% of the free space
# lvextend -l +25%FREE /dev/mapper/vg01_data-lv_data
to increase it to use all of the free space
# lvextend -l +100%FREE /dev/mapper/vg01_data-lv_data
8a. then create a xfs file system
# mkfs /dev/vg_oracle/lv_u01
8b. or resize the xfs file system
# xfs_growfs /u01