Add Quotes and Commas to a List of Words in Bash

You have a file with a list of items and you need to put them all in quotes. All but the last line needs to have a comma at the end.

Here is the list:

$ cat testfile.txt
apple
pear
grape
orange

Use sed to make the change:

sed -i 's/^/"/; $!s/$/",/; $s/$/"/' testfile.txt

Here is the list after:

$ cat testfile.txt
"apple",
"pear",
"grape",
"orange"

Repartition a USB Thumbdrive

Disk manager won’t let you do it. Here’s how you make it happen in Windows without a 3rd party application.

1 – Open an elevated command prompt.
2 – Run diskpart
3 – list disk

Find the disk number from the list of disks, make sure you have the right on!

DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 238 GB 0 B *
Disk 1 Online 7728 MB 7239 MB

4 – list partition (There should only be a 0 and 1 partition number)
5 – select partition 0
6 – delete partition
7 – select partition 1
8 – delete partition
9 – create partition primary
10 – exit

Now you can use Disk Manager to format and name the volume

Shrink LVM Volume – Ubuntu

Boot from an Ubuntu LiveCD

Locate the volume group that you wish to shrink
ubuntu@ubuntu:~$ sudo lvmdiskscan

ubuntu@ubuntu:/dev$ sudo lvmdiskscan
/dev/ram0 [ 64.00 MiB]
/dev/loop0 [ 1.41 GiB]
/dev/ubuntu-vg/root [ 460.32 GiB]

Issue the following command to shrink the file system and the volume
ubuntu@ubuntu:~$ sudo lvreduce –resizefs –size -230G /dev/ubuntu-vg/root

Reboot