Bash script to extract wifi passwords from NetworkManager This is my first shell script, so I am trying to see if I can get some suggestions. It extracts saved wifi passwords from Linux. 

##################################################################

# This script is used to copy wifi password files from /etc/NetworkManager/system-connections folder

# check if the wifi_pass_dir exists, and delete it if it does
if [ -d "wifi_pass_dir" ]
then
    rm -rf wifi_pass_dir
fi

# Create wifi_pass_dir folder
mkdir wifi_pass_dir


#copy the files from NetworkManager to the folder created, these files can only be read by the root user so use sudo
sudo cp /etc/NetworkManager/system-connections/* ./wifi_pass_dir


# change the file permission from read only by root to read and write by any user (666) 
sudo chmod 666 ./wifi_pass_dir/*

#create a list so we know what wifi passwords are saved
sudo ls /etc/NetworkManager/system-connections &gt; ./wifi_pass_dir/pass_list.txt

# Read name of wifi from pass_list.txt and print on screen 
cd wifi_pass_dir
filename="pass_list.txt"

while read -r line
do 
    name="$line"
    echo $name 
    cat "$name" | grep psk=
done &lt; "$filename"
##################################################################
General
Always include a shebang, and set options to exit the script when a command fails or when we use a variable that's not set:
#!/bin/bash

set -eu

Test for existence with -e, not -d
If wifi_pass_dir exists, but is not a directory (perhaps it's a plain file), it will not be deleted, and the mkdir will fail.  It might be better not to check (rm -f will succeed if the file doesn't exist):
# Ensure the wifi_pass_dir exists
rm -rf wifi_pass_dir
mkdir wifi_pass_dir

However, I don't believe it's necessary to copy the config files to an insecure location and make them world readable (and writeable) - see later.
sudo is for interactive use, not scripts
Avoid using sudo in a script - it expects to be interactive, and won't necessarily do what you want if not connected to a terminal.  It's easier to require that the script be run under sudo (and we can then use su to change to a non-privileged user where necessary).
Don't parse the output of ls
Filenames you don't control can contain all sorts of characters, including newlines.  Here, we don't need to do that, as we're reading from a directory.  The while read loop can simply be a for f in * loop.
Don't over-exercise the cat
This cat isn't needed:
cat &quot;$name&quot; | grep psk=

Just tell grep to take its input from $name directly:
grep psk= &quot;$name&quot;

We don't even need a loop, as we can pass all the filenames to grep in one go.

Simplified code
#!/bin/bash
exec grep 'psk=' /etc/NetworkManager/system-connections/*

Yes, that's the whole program.  Since we only execute one command, we don't need set -e, and as we use no variables, neither do we need set -u.