New answers tagged


In Unix, files (and directories are just files) don't have "names". Links have names, links are entries in a directory that map names to files. You might say, that links give names to files, but note: this implies that a file can have more than one name, since it can have more than one link. Since the root directory is, well, the root directory, there is ...


The POSIX standard says A pathname consisting of a single / shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. It makes a distinction between filenames and pathnames. / is a pathname for the path of the root directory. The name of the directory is "the root directory", but in the filesystem it is ...


The use of the word "name" is a little bit flexible; it can refer to a "fully qualified path name"; it could refer to the "directory entry"; it could refer to the "file name" passed to various functions or routines. So, for example, /etc/foo and /var/tmp/../../etc/foo and /tmp/../../../../../../foo are all ways of referring to the same file; they're all ...


slash is a separator; directory names do not include separators, but full pathnames include the separators. So the "root-level" "/" has no name. On most Unix-like systems, this is treated as a special case like "." and ".." (though of course there is no difference between the two at the root level). Nomenclature can differ. POSIX, for example lists some ...


"_" or "-" or other symbols do not have any impact at all, only the following letters are relevant for sorting. It's really annoying but I guess sort options are too hard to code for the devsā€¦


I suspect you are using a mount command like the one below: mount -t msdos /dev/XYZ /mnt/test This will force the partition to be mounted in legacy DOS FAT filesystem which uses the 8.3 filename convention (See instead of vfat which uses Long filenames ( ...


It is probably the file-system on the usb-storage. FAT file system can only support file-names of 8+3 characters. This file-system is very old. It is only needed for backwards compatibility with very old systems. FAT also only support upper-case characters. As this is only one case, there is an option to map this to lower-case. This makes thing more ...


Using sed $ printf "%s\n" * | sed 's/.csv$//; s/_/\t/g' abc q1 w1 defg q11 w2 hijk q11 w3 How it works: printf "%s\n" * prints the file names one per line s/.csv$// removes the trailing .csv. s/_/\t/g converts the _ to tabs. Using bash $ for f in *; do f="${f%.csv}"; printf "%s\n" "${f//_/$'\t'}"; done abc q1 w1 defg ...


You could use something like: ls -1 | tr '_' '\t'


You should not use an extension for executables, as they they are not interchangeable. Imagine that you have a shell script, then re-write in python, you now have to change every program that calls you script, you have leaked implementation detail. The whole file-name extension thing in Mircosoft's Windows is a mess: for example what could have ...


This is my solution to adding a time stamp when moving files in bash #!/usr/bin/env bash cd "FILES_LOCATION" COPYDIR="NEW_FILE_LOCATION" for file in *.FILE_EXTENSION; do NEWAPPEND=$(date +%s) cp $file "$COPYDIR"/"$NEWAPPEND"$file rm $file done


To List all PNG and JPEG files which are 7 days old with absolute path. $ find $PWD/ -mtime -7 -print -exec grep -e ".png\|.jpg" {} \; Here $PWD will be added to every file matched.


Unorthodox approach: zsh -c 'echo $PWD/**/*.gz(.om[1])' where () after *.gz means to use so called glob qualifiers, i.e.: . consider only plain files om sort by modification time [1] take only first element Obviusly if you are already using zsh you don't need to call it with zsh -c.


You can do that by using this command, find "$(pwd)" -type f -name "*.gz" -printf "%T@ %p\n"| sort -n | cut -d' ' -f 2 | tail -n 1

Top 50 recent answers are included