How can I find exactly which files have been accessed after a command runs in tcsh?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












how can I find which files tcsh reads to TAB complete the second word of a command, as opposed to the first word.



I know I can just use whereis complete to see the path to *.1.gz file, but that is not specific enough to say which files are being used.



On the other hand, if I use locate complete, I am given a list of a couple hundred files, many of which aren't executable.










share|improve this question



























    up vote
    0
    down vote

    favorite












    how can I find which files tcsh reads to TAB complete the second word of a command, as opposed to the first word.



    I know I can just use whereis complete to see the path to *.1.gz file, but that is not specific enough to say which files are being used.



    On the other hand, if I use locate complete, I am given a list of a couple hundred files, many of which aren't executable.










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      how can I find which files tcsh reads to TAB complete the second word of a command, as opposed to the first word.



      I know I can just use whereis complete to see the path to *.1.gz file, but that is not specific enough to say which files are being used.



      On the other hand, if I use locate complete, I am given a list of a couple hundred files, many of which aren't executable.










      share|improve this question















      how can I find which files tcsh reads to TAB complete the second word of a command, as opposed to the first word.



      I know I can just use whereis complete to see the path to *.1.gz file, but that is not specific enough to say which files are being used.



      On the other hand, if I use locate complete, I am given a list of a couple hundred files, many of which aren't executable.







      path tcsh locate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 13 at 1:15

























      asked Sep 13 at 0:58









      Alexander Wolf

      12




      12




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          I'd use strace to capture the whole session, and pick up the keyboard-read by browsing the script output, and then find all of the open-calls after that. That works with Linux and some other systems. There's a similar trace for BSD's (MacOS is a different story though).



          However, tcsh likely is not opening the files but listing them from the directory. strace would help with that, too. For instance, in a quick check I see it opening the current directory using openat



          openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3


          and then using the lstat function to determine what the entries of interest are (so that it can sort them, decide which are files versus directories, etc):



          lstat("xterm.desktop", 0444, st_size=1921, ...) = 0


          The "." is the current directory. The program reads a list of directory entries which may be files, directories, symbolic links, etc., but those are not sorted (and types are unknown, until it uses stat/lstat to ask).



          locate and whereis won't show useful data, since they do not use the same rules for finding the files as tcsh.






          share|improve this answer






















          • Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
            – Alexander Wolf
            Sep 13 at 3:24










          • st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
            – Alexander Wolf
            Sep 13 at 19:11










          • You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
            – Thomas Dickey
            Sep 13 at 19:49










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468678%2fhow-can-i-find-exactly-which-files-have-been-accessed-after-a-command-runs-in-tc%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          I'd use strace to capture the whole session, and pick up the keyboard-read by browsing the script output, and then find all of the open-calls after that. That works with Linux and some other systems. There's a similar trace for BSD's (MacOS is a different story though).



          However, tcsh likely is not opening the files but listing them from the directory. strace would help with that, too. For instance, in a quick check I see it opening the current directory using openat



          openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3


          and then using the lstat function to determine what the entries of interest are (so that it can sort them, decide which are files versus directories, etc):



          lstat("xterm.desktop", 0444, st_size=1921, ...) = 0


          The "." is the current directory. The program reads a list of directory entries which may be files, directories, symbolic links, etc., but those are not sorted (and types are unknown, until it uses stat/lstat to ask).



          locate and whereis won't show useful data, since they do not use the same rules for finding the files as tcsh.






          share|improve this answer






















          • Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
            – Alexander Wolf
            Sep 13 at 3:24










          • st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
            – Alexander Wolf
            Sep 13 at 19:11










          • You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
            – Thomas Dickey
            Sep 13 at 19:49














          up vote
          1
          down vote













          I'd use strace to capture the whole session, and pick up the keyboard-read by browsing the script output, and then find all of the open-calls after that. That works with Linux and some other systems. There's a similar trace for BSD's (MacOS is a different story though).



          However, tcsh likely is not opening the files but listing them from the directory. strace would help with that, too. For instance, in a quick check I see it opening the current directory using openat



          openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3


          and then using the lstat function to determine what the entries of interest are (so that it can sort them, decide which are files versus directories, etc):



          lstat("xterm.desktop", 0444, st_size=1921, ...) = 0


          The "." is the current directory. The program reads a list of directory entries which may be files, directories, symbolic links, etc., but those are not sorted (and types are unknown, until it uses stat/lstat to ask).



          locate and whereis won't show useful data, since they do not use the same rules for finding the files as tcsh.






          share|improve this answer






















          • Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
            – Alexander Wolf
            Sep 13 at 3:24










          • st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
            – Alexander Wolf
            Sep 13 at 19:11










          • You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
            – Thomas Dickey
            Sep 13 at 19:49












          up vote
          1
          down vote










          up vote
          1
          down vote









          I'd use strace to capture the whole session, and pick up the keyboard-read by browsing the script output, and then find all of the open-calls after that. That works with Linux and some other systems. There's a similar trace for BSD's (MacOS is a different story though).



          However, tcsh likely is not opening the files but listing them from the directory. strace would help with that, too. For instance, in a quick check I see it opening the current directory using openat



          openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3


          and then using the lstat function to determine what the entries of interest are (so that it can sort them, decide which are files versus directories, etc):



          lstat("xterm.desktop", 0444, st_size=1921, ...) = 0


          The "." is the current directory. The program reads a list of directory entries which may be files, directories, symbolic links, etc., but those are not sorted (and types are unknown, until it uses stat/lstat to ask).



          locate and whereis won't show useful data, since they do not use the same rules for finding the files as tcsh.






          share|improve this answer














          I'd use strace to capture the whole session, and pick up the keyboard-read by browsing the script output, and then find all of the open-calls after that. That works with Linux and some other systems. There's a similar trace for BSD's (MacOS is a different story though).



          However, tcsh likely is not opening the files but listing them from the directory. strace would help with that, too. For instance, in a quick check I see it opening the current directory using openat



          openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3


          and then using the lstat function to determine what the entries of interest are (so that it can sort them, decide which are files versus directories, etc):



          lstat("xterm.desktop", 0444, st_size=1921, ...) = 0


          The "." is the current directory. The program reads a list of directory entries which may be files, directories, symbolic links, etc., but those are not sorted (and types are unknown, until it uses stat/lstat to ask).



          locate and whereis won't show useful data, since they do not use the same rules for finding the files as tcsh.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 13 at 8:45

























          answered Sep 13 at 1:39









          Thomas Dickey

          50.3k587157




          50.3k587157











          • Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
            – Alexander Wolf
            Sep 13 at 3:24










          • st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
            – Alexander Wolf
            Sep 13 at 19:11










          • You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
            – Thomas Dickey
            Sep 13 at 19:49
















          • Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
            – Alexander Wolf
            Sep 13 at 3:24










          • st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
            – Alexander Wolf
            Sep 13 at 19:11










          • You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
            – Thomas Dickey
            Sep 13 at 19:49















          Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
          – Alexander Wolf
          Sep 13 at 3:24




          Okay, so I found the spot in strace when tab completed the word. I typed echot and it was completed to echotc. However, I cannot discern what files were accessed in the process. The only open command that I see inbetween is " openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 ".
          – Alexander Wolf
          Sep 13 at 3:24












          st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
          – Alexander Wolf
          Sep 13 at 19:11




          st_mode is just telling me the file type and mode? Can I get further information on which files were actually consulted to excute TAB complete properly, after tcsh used lstat?
          – Alexander Wolf
          Sep 13 at 19:11












          You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
          – Thomas Dickey
          Sep 13 at 19:49




          You could read tcsh's source-code. Offhand, the reason why it does the lstat's is to determine which entries it can show. Assume it showed all of those for which the lstat was performed.
          – Thomas Dickey
          Sep 13 at 19:49

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468678%2fhow-can-i-find-exactly-which-files-have-been-accessed-after-a-command-runs-in-tc%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)