#!/bin/bash

user=$(whoami)

cd /tmp/

sudo sed -i.bak \
  -e "s/^[[:space:]]*${user}[[:space:]]\+core[[:space:]]\+unlimited[[:space:]]*$/${user} hard core unlimited/" \
  -e "s/^[[:space:]]*${user}[[:space:]]\+hard[[:space:]]\+memlock[[:space:]]\+ulimited[[:space:]]*$/${user} hard memlock unlimited/" \
  -e "s/^[[:space:]]*${user}[[:space:]]\+soft[[:space:]]\+memlock[[:space:]]\+ulimited[[:space:]]*$/${user} soft memlock unlimited/" \
  /etc/security/limits.conf

sudo grep -nE "^[[:space:]]*${user}" /etc/security/limits.conf
