I want to unmount multiple CIFS shares on my AIX LPAR using for loop. I created a file named cifs.txt containing all CIFS shares. Will my command work?

for i in $(cat cifs.txt); do rmcifsmnt -f $i; done
New contributor
RJ Gellangarin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    You're calling rmcifsmnt which "Removes a CIFS mount from the /etc/filesystems file and unmounts the entry if it is mounted" but only "want to unmount". Which do you want? – Jeff Schaller May 16 at 1:41

Your existing loop runs the risk of expanding any wildcards in the filenames and removes the corresponding mount(s) from /etc/filesystems. If the mounts are given, one per line, in cifs.txt, then to unmount them:

< cifs.txt xargs -n 1 umount


< cifs.txt xargs -n 1 rmcifsmnt -N -f

Correspondingly, if you want to unmount them and remove them from /etc/filesystems:

< cifs.txt xargs -n 1 rmcifsmnt -f

xargs will do the work of parsing cifs.txt line-by-line and passing each line as an argument to the umount or rmcifsmnt commands (at the end).

Your Answer

RJ Gellangarin is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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