Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    I can't get this to work. Try this instead /bin/bash -lixc exit 2>&1 | awk 'match($0, /^+* (\.|source) (.+)/, s) {print s[2]}'. I also find that strace does a better job: strace -t -e trace='openat' --decode-fds -e signal=none bash -lic exit 2>&1 | grep -P --no-color 'openat.+(?<!\(No such file or directory\))$' Commented Apr 13, 2021 at 19:30
  • 1
    @smac89 if you want your strace to work on WSL as well, use the following strace -e trace='openat' -e signal=none bash -lic exit 2>&1 | cut -d\" -f2 | grep -Ev "locale/|langpack|/dev/null|/dev/tty|^*/$|+++ exited|logout|.*so.*" to get the proper list of config files only, without the fancy stuff. Commented Jul 31, 2021 at 18:30
  • 1
    This is only half of a good idea.  Yes, -x will show all the commands that the shell executes, but the OP is interested in the initialization files that bash runs automatically, and -x does not show these as source or . commands.  A better answer would be to tell the OP to look at the full -x output, figure out what commands are being executed, and then grep everything to find out what files those commands are in. … (Cont’d) Commented Apr 12, 2022 at 5:33
  • 1
    (Cont’d) … A slightly better approach would be to use -v and see the literal contents of the initialization files — that will show comments, and many system shell script files have header comments giving their names. … … … … … … … … … … … … … … … … … … … … P.S.  You talk about “the source command or the . alias.”  I believe that there is a command that simply has two names.  Can you provide a reference for your claim that . is only an alias for source? Commented Apr 12, 2022 at 5:33
  • This was the only solution that worked for me (Using bash in Alpine linux). Commented Jun 9, 2022 at 19:02