Tag Info

Hot answers tagged

8

From man bash: If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized. In the following description, a pattern-list is a list of one or more patterns separated by a |. Composite patterns may be formed using one or more of the following sub-patterns: ?(pattern-list) ...


7

Use find instead? find /my/example/dir -type f -name '*.sas' ! -name 'qc_d[ltf]*'


4

Use the file command. [sreeraj@server ~]$ ls -l mytest lrwxrwxrwx 1 sreeraj sreeraj 15 Dec 12 09:31 mytest -> /usr/sbin/httpd [sreeraj@server ~]$ file mytest mytest: symbolic link to `/usr/sbin/httpd' or [sreeraj@server ~]$ file -b mytest symbolic link to `/usr/sbin/httpd' [sreeraj@server ~]$ Also, please go read through man page of ls and check ...


3

ls unfortunately doesn't have an option to retrieve file attributes and display them in an arbitrary way. Some systems have separate commands for that (for instance GNU has a stat command or the functionality in GNU find). On most modern systems, with most files, this should work though: $ ln -s '/foo/bar -> baz' the-file $ LC_ALL=C ls -ldn the-file | ...


3

Assuming file names don't contain newline characters and don't start with ., this should work: ls -d -- *.sas | grep -v '^qc_d[ltf]' List files ending in .sas and filtering all that is NOT qc_dl, qc_dt, qc_df For any filtering needs, grep is your friend.


3

I think you want this command: ls -l partition | cut -c5-7 | tr rwx cse |sed 's/-//' You can remove the one extra command(cut -d ' ' -f 1) and replace it with your last cut command(cut -c5-7) and also add sed 's/-//' at the end to remove all -s. Now you are done. you didn't need to adding extra |. And even better: you can also change the dash(- ...


3

Wouldn't it be easier to use find with the -nogroup flag? For example: find /var/indexes -nogroup If you want to base the script around ls then awk is tool I'd use to select columns.


2

Alternative way without ls: getfacl -c partition | sed -n '/group::/{s/.*:://;y/rwx/cse/;s/-//g;p;}'


2

Both redirect stdout to file. ls > list If file exists it'll be replaced. ls >> list If file not exists it'll be created. If it exists, it'll be appended to the end of file. Find out more: IO Redirection


2

The command you have above will (somewhat clumsily) rename all files in the current directly from *.jpg to *.jpeg, it could be modified to delete all files but is hardly appropriate to the task. However, it sounds like you are trying to craft a suitable filename such that when the above command encounters it, it will delete everything in the current ...


1

The most likely scenario is that you accidentally gave all files in the directory execute permission.


1

With a GNU ls at least (and, apparently, tcsh's implementation) you can hack the $LS_COLORS environment variable to insert delimiters where you like (but tcsh's builtin ls-F doesn't do link targets - only link flags) Usually ls inserts arbitrary non-printable terminal escapes based on the values stored within that environment var, but there's nothing ...


1

You don't really want to do this in bash, but because you asked, this is how you could split it up. #!/bin/bash re='^[0-9]+$' for x in `/usr/bin/ls -l --time-style=+'%s' /var/indexes | sort -k3,3 | awk '{print $3 $7}'` do read -A nm <<< "$x" if [[ ${nm[0]} =~ $re ]] ; then echo "found one " ${nm[1]} fi done It's easier in awk like so: ...


1

Another alternative (piping two tr commands): ls -l partition | cut -c5-7 | tr -dc rwx | tr rwx cse


1

Why not just delete the annals directory? # rm -r /run/media/Harry/CA6C321E6C32062B/annals Note: It looks like it's been in a Windows machine as it has a System Volume Information directory. This means it's probably NTFS? If that's the case, then you'd be better off formatting it with a more *nix friendly filesystem. Of course, that assumes you don't ...


1

If you are using bash try to put this in your bashrc/bash_profile: alias cd='cd $1 && ls -lrth' UPDATE: This is not correct, i just double checked it, it is just listing the dir you did want to cd in but it stays in your actual dir where you launched the command. UPDATE 2: You have to create a bash function instead of an alias it is much safer ...



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