Tag Info

Hot answers tagged

13

Don't parse ls. Also don't use ALL_CAPS_VARS for i in "$incoming_dir"/*"$business_date"*; do Interactively, ls has a -d option that prevents descending into subdirectories: ls -d $INCOMINGDIR/*$BUSSINESSDATE*


13

This file is under a directory matching the pattern, use: ls -d ./[[:upper:]]* By default, when passed a directory name as argument, ls displays its content, not its name. The -d option is disabling this feature. When using the [[:upper:]]* pattern, the shell is expanding it to every filename starting with an uppercase letter so ls receives the expanded ...


5

TL;DR bash opens and truncates all involved files before anything is written to them. stdout and stderr are both sent to new because bash has already truncated the file (twice) when ls starts printing. This is how bash prepares/handles I/O redirection. When you ask for a command to be redirected (>) to a file, bash basically opens that file, creating it ...


5

There is no reason why this command should be recursive. But if $INCOMINGDIR/*$BUSSINESSDATE* matches a directory then the content of this directory is shown instead of the directory itself. But there would be no recursion beyond this level. Use this command to avoid that effect: ls -d "$INCOMINGDIR/"*"$BUSSINESSDATE"* for ... in commands with ls output ...


2

If you're refering to the output of ls, its manpage sent me to the LS_COLORS environment variable and the dircolors helper program that can turn a list of specifications (extensions and the like, including special values like LINK and DIR) into the LS_COLORS you want. dircolors --print-database will give you commented default settings.


2

You don't get both contents appended. You will get a weird output: $ ls testasdasd qtsingleapp-homecu-bcbf-3e8 >new 2>new $ cat new qtsingleapp-homecu-bcbf-3e8 : No such file or directory If you have both contents, you should see: $ ls testasdasd qtsingleapp-homecu-bcbf-3e8 >new 2>&1 $ cat new ls: cannot access testasdasd: No such file or ...


2

Just use I/O redirection , writing output of ls command to a file solves this. ls -l /bin > files.txt


2

You can use the -F parameter to ls to get: -F, --classify append indicator (one of */=>@|) to entries i.e.: # ln -s videos Videos # ls -l lrwxrwxrwx. 1 guido guido 6 Jan 23 14:11 videos -> Videos # ls -lF lrwxrwxrwx. 1 guido guido 6 Jan 23 14:11 videos -> Videos/ Anyway, I'd suggest you create symlinks to directories like ...


1

The output of ll, which I assume is a shell alias for ls -l, does not contain this information in the mode/permissions of the symlink. On Linux (symlink(2)): The permissions of a symbolic link are irrelevant; the ownership is ignored when following the link, but is checked when removal or renam- ing of the link is requested and the link is ...


1

The straightforward way : find . -maxdepth 1 -type d -name '.*' find . -maxdepth 1 -type d \! -name '.*' find . -maxdepth 1 -type f -name '.*' find . -maxdepth 1 -type f \! -name '.*'


1

Colorized ls for AIX(with Perl). Works for most flavors of Unix too, like Sun etc.



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