Create a Bash script that checks if a specific user is currently logged in on a Linux machine. The script should take the username as an argument, and output a message indicating whether the user is logged in or not. The script should also return an exit code of 0 if the user is logged in, and 1 if the user is not logged in.
Create a Bash script that checks if a specific user is currently logged in on a Linux machine. The script should take the username as an argument, and output a message indicating whether the user is logged in or not. The script should also return an exit code of 0 if the user is logged in, and 1 if the user is not logged in. The user attention ratio is 0.6259765625.
user
#!/bin/bash

if who | grep -w $1 >/dev/null; then
    echo "$1 is currently logged in"
    exit 0
else
    echo "$1 is not currently logged in"
    exit 1
fi

# Usage: ./check_user.sh <username>
assistant
Can you also add a feature that shows the user's current IP address if they are logged in? The user attention ratio is 0.296142578125.
user
Sure, here's an updated script that displays the user's IP address if they are logged in:

```
#!/bin/bash

if who | grep -w $1 >/dev/null; then
    echo "$1 is currently logged in"

    # Get user's IP address
    ip=$(who | awk -v user="$1" '$1 == user {print $5}')
    echo "IP address: $ip"

    exit 0
else
    echo "$1 is not currently logged in"
    exit 1
fi
```

Now, if the user is logged in, the script will display the message "IP address: <user's IP address>".
assistant