The meaning of a few lines of code in the shell script

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    -sharp The file bash.bashrc already sets the default PS1.
    -sharp PS1="\h:\w\$ "
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1="-sharp "
    else
      PS1="$ "
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

I"d like to ask shell what the-f and-r of these lines of code mean

Mar.02,2021

-e filename if filename exists, true
-d filename if filename is a directory, true
-f filename if filename is a regular file, true
-L filename if filename is a symbolic link, true
-r filename if filename is readable, true
-w filename if filename is writable, true
-x filename if filename is executable, true
-s filename if the file length is not zero. True
-h filename if the file is a soft link, true


there is a website that can explain the shell command: shell.com" rel=" nofollow noreferrer "> https://explainshell.com

write down a command-line to see the help text that matches each argument

for example, put the if [- f / etc/bash.bashrc]; then. In your script / etc/bash.bashrc; fi put it in explainshell:

shell.com/explain?cmd=if+%5B+-f+%2Fetc%2Fbash.bashrc+%5D%3B+then+.+%2Fetc%2Fbash.bashrc%3B+fi" rel=" nofollow noreferrer "> https://explainshell.com/expl.

clipboard.png

as shown above, -f has a clear explanation. And so on, you can view other content on your own.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b372d6-2c059.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b372d6-2c059.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?