Is output of a "dir" command same in all distributions of Linux? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm preparing a batch compiling sh file in Ubuntu. It is using dir command to get a list of files (and some string processing to extract names). But this may not be the best way (but easy enough) of getting list.
Question: do all Linux distros answer "dir" command same?
dir /usr/lib/nvidia-*
/usr/lib/nvidia-396:
alt_ld.so.conf libnvidia-cfg.so.396.54
bin libnvidia-compiler.so
ld.so.conf libnvidia-compiler.so.1
libEGL_nvidia.so.0 libnvidia-compiler.so.396.54

Yes, the dir tool should work the same across any distribution, provided the distribution doesn't have its own modified version or has this tool missing etc.
You might find this helpful for some background into dir tool
https://www.howtoforge.com/linux-dir-command/

You can use tree command to get all files and filter whatever you want.
tree -f -i .|grep .*\.py$ here it greps all .py files.
here's tree doc
example:
root#fdada3432377:/usr/src/app# tree -f -i conn* |grep .*\.py$
connection/__init__.py

Related

Exclude a directory from plocate on Linux? [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 days ago.
Improve this question
So after using the locate command on Linux Mint a lot, I ran into the issue of every query returning rows upon rows of results in the /timeshift/ directory - what Linux Mint uses as OS save points.
If I used, say, locate anaconda activate.sh, what I might get is:
/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts
/conda-activate.sh
/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/deactivate.d/deactivate.sh
/timeshift/snapshots/2023-01-09_15-00-01/localhost/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-10_04-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-10_04-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/deactivate.d/deactivate.sh
/timeshift/snapshots/2023-02-14_20-00-01/localhost/home/user/.anaconda3/pkgs/spyder-5.1.5-py39h06a4308_1/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-15_21-00-01/localhost/home/user/.anaconda3/lib/python3.9/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh
/timeshift/snapshots/2023-02-15_21-00-01/localhost/home/user/.anaconda3/pkgs/conda-4.12.0-py39h06a4308_0/info/test/tests/test-recipes/activate_deactivate_package/src/etc/conda/activate.d/activate.sh
Only the top three results are relevant, so how would one exclude a directory?
Manually exclude a directory with grep
You can use the -v option to get grep to output all the elements that don't match the supplied Regex, like so:
locate anaconda activate.sh | grep -v "/timeshift/"
This will print only paths which don't contain the string /timeshift/
Permanently exclude a directory
Since the issue with the timeshift directory is a frequently re-occuring one, you might want to permanently exclude it from all plocate queries.
As per the updatedb documentation, you may add /timeshift to PRUNEPATHS= in /etc/updatedb.conf. Once updatedb has been run, all plocatequeries should now exclude the /timeshift directory.

How to add alternative to program that located in /usr/bin [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Is it possible to substitute binary with same name alternative? I have /usr/bin/qtcreator
I want to use alternative version but /usr/bin/qtcreator is binary but not alternative.
What the way I should do this?
You could place your new qtcreator at /usr/local/bin/qtcreator, that location should have preference over /usr/bin.
You can check the possible locations for binaries and the order is which they are searched with echo $PATH and you can check which binary will be called with which qtcreator
In Bash:
$ alias qtcreator="/usr/local/bin/qtcreator"
or make sure the path to desired binary is mentioned before the undesired path in $PATH (... as mentioned by others).

how to deal with file without a name in linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm a green hand to linux using the vmware called Parallels on my mac and the edition I use is CentOS7.When I use the ls -al command, I found some files don't have name as follow in surprise:
I just want to know as these files are seemingly generated at a same time, what are they? how to delete them?
On *nix system every file has an atrribute called i-node. You can find with command
ls -i
when you have i=node number you can delete file by
find . -inum 782263 -exec rm -i {} \;
You could use any other commands not only rm.
more details you can find here
http://www.cyberciti.biz/tips/delete-remove-files-with-inode-number.html
As the d in drwxr-xr-x states, those are folders (or at least the filesystem thinks they are). You may use Midnight Commander to delete them. You may already have it installed on your machine, try to run mc to see if it's there.

Unix shell directory history [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
The history feature is great for remembering commands. Is there a feature that remembers recent directories?
I'd like to be able to search through a history of directories - it'd be even better if it was possible to bookmark and name them, as you can do in a browser.
You can do cd -1 to get back to the previous directory, cd -2 to get to the former etc.. You can also refer to them using ~1, like cp ~1/README.md ~2/
For a more advanced use, you can use the dirs builtin. You can also use pushd and popd to stack up directories and get back to them later on, pretty useful in scripts.
cf the directory stack
Zsh has the same facility, the dirstack. And with zsh, you can have more fun with directory bookmarks,
Finally, there's even a crazy guy who implemented a GUI for listing the dirstack. Not sure how useful that can be, but it's definitely crazy enough to be referred :-)
HTH
To save directories and keep a historial, you can try pushd and popd from bash

How to delete file named "-d" in unix(Mac OSX) from command line? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I was playing with tail, head, cut and awk commands on a text file and somehow these commands created empty files with names "-d" and "-f2" (It could be due to ). Now I am not able to delete these files from command line since all commands take these as options. Of course I can delete these from Finder but I am wondering how to delete these from command line.
Use -- to separate the files from the command line arguments. That is
rm -- -d -f2
Or, you can use the full path or a relative path containing at least a /:
rm ./-d ./-f2

Resources