Tag Info

Hot answers tagged

12

In most shells including bash, pwd is a shell builtin: $ type -a pwd pwd is a shell builtin pwd is /bin/pwd If you use /bin/pwd, you must use the -L option to get the same result as builtin pwd: $ ln -s . test $ cd test && pwd /home/cuonglm/test $ /bin/pwd /home/cuonglm $ /bin/pwd -L /home/cuonglm/test By default, /bin/pwd ignores symlinks and ...


7

For the stated question you can use find: find . -mindepth 1 ! -type l will list all files and directories in the current directory or any subdirectories that are not symlinks. mindepth 1 is just to skip the . current-directory entry. The meat of it is the combination of -type l, which means "is a symbolic link", and !, which means negate the following ...


6

From version 2.12 onwards, the -r option for GNU grep doesn’t dereference symbolic links unless you specify them by hand: -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option. -R, --dereference-recursive ...


5

Edit in response to updated question Since you only care about links, directories and regular files, and don't need to deal with the other filetypes that ls can identify (FIFOs, sockets etc), you could do something like stat. For the examples below, I have created the following test environment: $ ls -l total 4.0K -rw-r--r-- 1 terdon terdon 0 Jun 30 ...


3

In zsh, this would be easy thanks to glob qualifiers: grep PATTERN **/*(.) The pattern **/ traverses subdirectories recursively. The glob qualifier . restricts matching to regular files. Without zsh, use find (see Michael Horner's answer). And in this particular case, GNU grep can do what you want (it's exactly what grep -r does) — but only since version ...


3

For all users on your machine: writing to /usr/bin The script itself suggests a method for providing an alternative to iceweasel. I presume that the script is called /usr/bin/firefox. Thus, the line FIREFOX="$(which $0)" would set FIREFOX to /usr/bin/firefox. Thus, $FIREFOX.real would be /usr/bin/firefox.real. The line [ -x "$FIREFOX.real" ] && ...


2

Windows has a special syntax \\MACHINE\DIRECTORY…\FILE meaning the file located at \DIRECTORY…\FILE on the machine called \\MACHINE over the SMB protocol. This is built into the operating system and specialized to one network protocol. Linux has a flexible filesystem based on the notion of mounting. Filesystems are attached to an existing directory, and the ...


2

You can't: A symlink is simply an extra inode (a structure that points to the file) and this inode consists of, amongst other things, a deviceId and an inode pointer. The deviceId effectively points to a device special file within the /dev directory and the inode pointer points to a block on that device. Your network location of 10.0.1.103 does not and ...


1

You can use $LS_COLORS to do this. If your version of ls supports specifying the colors using that variable, you can define output per file type. It's builtin behavior and very configurable. So I created some files to demo this like: for f in 9 8 7 6 5 4 3 2 1 do touch "${f}file" && ln -s ./"${f}file" ./"${f}filelink" done So now I'll do: ...


1

Specifically for gnome, there's a debian alternative configuration called gnome-www-browser. Alternatives on debian provides a way of defining a set of possible site-wide alternatives for a given functionality. In the case of gnome browser, it is simply a symlink to the browser launched by the desktop whenever a browser is needed or invoked. You can ...



Only top voted, non community-wiki answers of a minimum length are eligible