I need to know how to replace this line in fstab:

tmpfs                   /dev/shm                tmpfs   defaults        0 0


tmpfs                   /dev/shm                tmpfs   defaults,size=4G        0 0

I tried:

sed '/^tmpfs/ s/defaults.*$/defaults,size=${MEM_SZ}G/' /etc/fstab

but output was without 0 0 and the size value didn't changed with the variable :

tmpfs                   /dev/shm                tmpfs   defaults,size=${MEM_SZ}G

I modified the sed and replace single quotes with double and added \t to insert tab

sed "/^tmpfs/ s/defaults.*$/defaults,size=${MEM_SZ}G\t 0 0/" /etc/fstab

Not the answer you're looking for? Browse other questions tagged or ask your own question.