Questions tagged [filenames]

File name is a name used to identify a file uniquely on given file system.

1185 questions
226
votes
9 answers

Looping through files with spaces in the names?

I wrote the following script to diff the outputs of two directores with all the same files in them as such: #!/bin/bash for file in `find . -name "*.csv"` do echo "file = $file"; diff $file /some/other/path/$file; read…
Amir Afghani
  • 7,083
  • 11
  • 26
  • 23
214
votes
8 answers

Why is looping over find's output bad practice?

This question is inspired by Why is using a shell loop to process text considered bad practice ? I see these constructs for file in `find . -type f -name ...`; do smth with ${file}; done and for dir in $(find . -type d -name ...); do smth with…
don_crissti
  • 79,330
  • 30
  • 216
  • 245
205
votes
11 answers

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 |…
Rabiani
149
votes
6 answers

How does Linux handle multiple consecutive path separators (/home////username///file)?

I'm working on a python script that passes file locations to an scp subprocess. That's all fine, but I'm in a situation where I may end up concatenating a path with a filename such that there's a double '/ in the path. I know that bash doesn't care…
Falmarri
  • 12,897
  • 17
  • 58
  • 71
124
votes
9 answers

On what systems is //foo/bar different from /foo/bar?

Throughout the POSIX specification, there's provision (1, 2, 3...) to allow implementations to treat a path starting with two / specially. A POSIX application (an application written to the POSIX specification to be portable to all POSIX compliant…
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
112
votes
3 answers

What's the difference between "realpath" and "readlink -f"

I've read a lot about the realpath command and how it has been deprecated with readlink -f being now recommended.  I have also seen in some places that the reason why realpath was introduced was for the lack of such functionality in readlink and…
Felipe Leão
  • 1,285
  • 2
  • 9
  • 10
111
votes
2 answers

What does dash "-" at the end of a command mean?

Given the following command: gzip -dc /cdrom/cdrom0/file.tar.gz | tar xvf – What does the - at the end of the command mean? Is it some kind of placeholder?
Eugene S
  • 3,444
  • 8
  • 29
  • 35
97
votes
2 answers

Location of the crontab file

as many (most?) others, I edit my crontab via crontab -e, where I keep all routine operations such as incremental backup, ntpdate, various rsync operations, as well as making my desktop background christmas themed once a year. From what I've…
Jarmund
  • 1,068
  • 1
  • 8
  • 11
85
votes
6 answers

recursive statistics on file types in directory?

I did a website scrape for a conversion project. I'd like to do some statistics on the types of files in there -- for instance, 400 .html files, 100 .gif, etc. What's an easy way to do this? It has to be recursive. Edit: With the script that…
user394
  • 14,194
  • 21
  • 66
  • 93
83
votes
1 answer

How to list files in a zip without extra information in command line

In my bash command line, when I use unzip -l test.zip I get the output like this: Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 810000 05-07-2014 15:09 file1.txt 810000 05-07-2014 15:09 …
рüффп
  • 1,677
  • 4
  • 27
  • 35
82
votes
4 answers

When should I use a trailing slash on a directory?

Possible Duplicate: How linux handles multiple path separators (/home////username///file) Most commands I use in linux behave exactly the same whether I include the trailing slash / character on the end of a directory name or not. For example: ls…
Cory Klein
  • 18,391
  • 26
  • 81
  • 93
82
votes
1 answer

Which Fedora package does a specific file belong to?

In the Debian family of OSes, dpkg --search /bin/ls gives: coreutils: /bin/ls That is, the file /bin/ls belongs to the Debian package named coreutils. (see this post if you are interested in a package containing a file that isn't installed) What is…
tshepang
  • 64,472
  • 86
  • 223
  • 290
77
votes
14 answers

Unix file naming convention

I was wondering what is the naming convention for files in Unix? I am not sure about this, but I think there is perhaps a universal naming convention that one should follow? For example, I want to name a file say: backup with part 2 and random…
user4740
77
votes
9 answers

Bulk rename, change prefix

How can I bulk replace the prefix for many files? I have a lot of files like TestSRConnectionContext.h TestSRConnectionContext.m I would like to change all them to CLConnectionContext.h CLConnectionContext.m How would I do this?
ErikTJ
  • 893
  • 1
  • 7
  • 6
77
votes
8 answers

Converting relative path to absolute path without symbolic link

Is there a Unix command to get the absolute (and canonicalized) path from a relative path which may contain symbolic links?
Benjamin
  • 1,505
  • 2
  • 18
  • 25
1
2 3
78 79