find . -mindepth 1 -maxdepth 1 -not -empty -type d
source: https://stackoverflow.com/questions/815668/how-to-list-non-empty-subdirectories-on-linux#comment625237_815668
find . -mindepth 1 -maxdepth 1 -not -empty -type d
tar -pczf MyFile.tar.gz /home/user/myDirectory/ --exclude=patternExample:
tar -pczf MyFile.tar.gz /home/user/myDirectory/ --exclude='*.txt'
tar -pczf MyFile.tar.gz /home/user/myDirectory/ --exclude="./directoryToExclude1" --exclude="./directoryToExclude2"Note that there is no "/" at the end of the path to the directory to exclude!
awk -F, '{print $1,$3,$2,$4}' OFS=; "FILE" > NEW_FILEwhere:
# Source function library. . /etc/rc.d/init.d/functions # Now you can use action: action $"Perform an action:" /bin/trueIn Centos 7, 'action' definition inside /etc/rc.d/init.d/functions is as the following:
# Run some action. Log its output. action() { local STRING rc STRING=$1 echo -n "$STRING " shift "$@" && success $"$STRING" || failure $"$STRING" rc=$? echo return $rc }
$ hostname MyHostameTo set hostname immediately:
$ hostname [MY_HOSTNAME]This will change the hostname of your system immediately, but the original hostname will be restored upon next reboot. To set hostname to be permant follow the instructions below. For systemd based distributions(newer version of different Linux distributions such as latest Ubuntu, Debian, CentOS, Fedora, RedHat, etc. ) use the hostnamectl command:
$ sudo hostnamectl set-hostname [MY_HOSTNAME]For sysvinit(in short init) based distributions(older linux distributions) edit /etc/hostname:
# vim /etc/hostnameAdd a new line for the hostname in /etc/hosts:
# vim /etc/hosts
127.0.0.1 [MY_HOSTNAME]And run:
# /etc/init.d/hostname restartFor RHEL/CentOS based systems that use init, edit /etc/sysconfig/network:
# vi /etc/sysconfig/network
/etc/sysconfig/network NETWORKING=yes HOSTNAME="[MY_HOSTNAME]" GATEWAY="192.168.0.1" GATEWAYDEV="eth0" FORWARD_IPV4="yes"
EINVAL A new segment was to be created and size < SHMMIN or size > SHMMAX, or no new segment was to be created, a segment with given key existed, but size is greater than the size of that segment.
[root@myhost]# ipcs ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x74010241 2818048 root 600 4 0 0x7401026c 2162689 root 600 4 0 0x00000000 3178498 root 644 52 2 0x74010240 2785283 root 600 4 0 0x00000000 3211268 root 644 16384 2 0x00000000 3244037 root 644 268 2 0x750ca262 3440646 root 644 2043293648 0 ------ Semaphore Arrays -------- key semid owner perms nsems 0x000000a7 0 root 600 1 ------ Message Queues -------- key msqid owner perms used-bytes messages 0x7504d462 9568256 root 666 0 0 0x7504d562 9601025 root 666 0 0 0x7504d662 2686978 root 666 0 0 0x7504d762 2719747 root 666 0 0 0x7504d862 5373956 root 666 0 0 0x7504d962 5406725 root 666 0 0 0x75108a62 9502726 root 666 0 0 0x000002bd 9535495 root 666 0 0 [root@myhost]# ipcrm -m 3440646 [root@myhost]# ipcs ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x74010241 2818048 root 600 4 0 0x7401026c 2162689 root 600 4 0 0x00000000 3178498 root 644 52 2 0x74010240 2785283 root 600 4 0 0x00000000 3211268 root 644 16384 2 0x00000000 3244037 root 644 268 2 ------ Semaphore Arrays -------- key semid owner perms nsems 0x000000a7 0 root 600 1 ------ Message Queues -------- key msqid owner perms used-bytes messages 0x7504d462 9568256 root 666 0 0 0x7504d562 9601025 root 666 0 0 0x7504d662 2686978 root 666 0 0 0x7504d762 2719747 root 666 0 0 0x7504d862 5373956 root 666 0 0 0x7504d962 5406725 root 666 0 0 0x75108a62 9502726 root 666 0 0 0x000002bd 9535495 root 666 0 0 [root@myhost]#