1
The ls command works fine for me in all other directories except my home directory, where I get the following error:
* Exit with code 1, no result found, command line was:?? locate -b -i [\^g]*g[\^a]*a[\^r]*r[\^b]*b[\^a]*a[\^g]*g[\^e]*e[\^.]*\.[\^c]*c locate: illegal option -- b
I was passing --color as an option to ls in my .bash_profile, but I got rid of all color settings in .bashrc and .bash_profile assuming that the '--' in --color was the problem. I reinstalled the coreutils package as well, but no avail. Any help would be appreciated. Thanks.
Do you have
.
in your$PATH
, and a file namedls
in your home directory? (Tip: tryecho *
to list files whenls
is broken.) – Spiff – 2018-08-29T19:54:30.7431Also can you
cd
to somewhere else and then dols $HOME
from there? I’m wondering if the problem is what directory you’re in (your current working directory when runningls
), or what directory you’re attempting to list. – Spiff – 2018-08-29T19:57:57.010What run string are you using? Check what
ls
runs by enteringtype -a ls
, both in your home directory and in another where it works as expected. – AFH – 2018-08-29T20:02:36.580@Spiff i do have a '.' in my $PATH variable. When I say echo $PATH, I see a '.' in Python.framework. Doing ls $HOME results in the same error. – rama – 2018-08-29T20:26:34.183
@AFH type -a ls returns "ls is /bin/ls" – rama – 2018-08-29T20:27:51.413
UPDATE: Even though 'ls' throws an error, it does list all my files including directories. I am able to pass other flags to ls as well BUT everything is listed in a single column regardless of my terminal window size - behavior that is not common when running ls in folders other than my home directory. – rama – 2018-08-29T20:31:37.603
ls
will choose a column width to suit the longest file name, so it needs only a single long file name of more than half the terminal width and everything will come out in a single column. I can't understand where the error message comes from, unless a previous error string was used as a file name, instead of being copied into a log file - if so, @Spiff's commandecho *
will show the same message. – AFH – 2018-08-29T20:58:54.977@AFH echo * shows the same error message, and I do not have a file named 'ls' in my home directory. – rama – 2018-08-29T21:00:14.490
I think that's the problem - you have a file of that name in your home directory, and its long name is enforcing the single column listing. – AFH – 2018-08-29T21:01:46.713
I am not able to see any file with the name 'ls' even though I am listing hidden files as well. The longest name in my home folder is that of a directory, and it has been there since a long time. – rama – 2018-08-29T21:08:30.127
1Do
ls >/dev/null; echo $?
-- what is the result? If the result is "0", then I suspect AFH is right. What if you dols | grep -v "Exit with code 1"
? – glenn jackman – 2018-08-29T21:08:32.260@glennjackman the result of the first command is 0. The output of the second command is: https://imgur.com/a/n7lLcLL
– rama – 2018-08-29T21:12:23.6431You have 2 files with strange names. To remove them:
rm -i ./*"Exit with code 1"* ./*"locate: illegal option"*
-- it may be one file with a newline in the name, hard to tell. – glenn jackman – 2018-08-29T21:46:50.713@glennjackman the response is no such file or directory. i will try renaming all files and folders in my home directory in an attempt to remove all newline characters. – rama – 2018-08-30T00:41:16.267
1UPDATE #2: Thank you all, I used ls -li to list all the files with their inode number and used 'find . -inum [inode-number] -exec rm -i {} ;' to remove the file. I do not know which file I removed and am not able to gauge its importance, but it is what it is. ls is back to normal. Once again, thank you for all your time and support. – rama – 2018-08-30T01:48:35.137