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

learn more… | top users | synonyms

38
votes
6answers
4k views

How linux handles multiple 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 ...
37
votes
2answers
2k views

Why do some Linux files have a 'd' suffix?

I am new to Linux. I observed some of the binary files and configuration file name s end with a d. What is reason for putting a d at the end of the file name? Like httpd, ospfd, pppd, syslogd, ...
33
votes
7answers
35k views

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 ...
30
votes
4answers
2k views

unix, difference between path starting with '/' and '//'

In unix/linux, any number of consecutive forwardslashes in a path is generally equivalent to a single forwardslash. eg. $ cd /home/shum $ pwd /home/shum $ cd /home//shum $ pwd /home/shum $ cd ...
23
votes
2answers
4k views

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?
22
votes
3answers
501 views

shellcheck is advising not to use basename: why?

I am trying out shellcheck. I have something like that basename "${OPENSSL}" and I get the following suggestion Use parameter expansion instead, such as ${var##*/}. From the practical point of ...
21
votes
10answers
6k views

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 ...
20
votes
9answers
4k views

How can I delete a file with no name

I somehow managed to create a file that doesn't seem to have a filename. I found some information regarding how to get more details of the file in the following thread. However, I tried some of the ...
16
votes
3answers
9k views

What charset encoding is used for filenames and paths on Linux?

Does it depend on what file system I use? For example, ext2/ext3/ext4 but also what happens when I insert one of those "joliet" CD-ROMs with ISO 9660? I've heard that POSIX contains some sort of spec ...
16
votes
3answers
5k views

bulk rename (or correctly display) files with special characters

I have a bunch of directories and subdirectories that contain files with special characters, like this file: robbie@phil:~$ ls test�sktest.txt test?sktest.txt Find reveals an escape sequence: ...
15
votes
0answers
281 views

Completing avfs fake directories in zsh

How can I tweak zsh's completion system to complete “fake” files in some circumstances? More precisely, the AVFS filesystem exposes archives as directories by creating a “fake directory” next to ...
14
votes
3answers
602 views

Newlines in filenames

I understand and accept the premise that defensive1 shell scripting is both prudent and, in the longer term, more sustainable. Many of the answers to text processing questions here follow this ...
14
votes
6answers
11k views

Grabbing the extension in a file name

How do I get the file extension from bash? Here's what I tried: filename=`basename $filepath` fileext=${filename##*.} By doing that I can get extension of bz2 from the path /dir/subdir/file.bz2, ...
13
votes
3answers
3k views

When should I use a trailing slash on a directory? [duplicate]

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 / ...
13
votes
3answers
2k views

Understanding Unix file name encoding

I have a hard time understanding how the file name encoding works. On unix.SE I find contradicting explanations. File names are stored as characters To quote another answer: Several questions about ...
12
votes
6answers
5k views

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 | sort ...
12
votes
4answers
7k views

Converting relative path to absolute path

Is there a *nix command to get absolute(and canonicalized) path from relative path(with current path) or symbolic link?
12
votes
2answers
269 views

Shell filename pattern that expands to dot files but not to `..`?

Recently I had a little mishap caused by a shell pattern that expanded in an unexpected way. I wanted to change the owner of a bunch of dot files in the /root directory, so I did chown -R root .* ...
11
votes
2answers
1k views

What is the difference between “du -sh *” and “du -sh ./*”?

The title says it all. What's the difference between those 2 commands? NOTE: I'm more interested in the * and ./* part.
10
votes
6answers
25k views

How to list files without directories, and filter by name (ls options)

I have a directory called uploads. It contains a bunch of files, plus a few subdirectories which in turn contain files. Is there a way I can (in one step) do the following: List ONLY the files in ...
10
votes
1answer
2k views

What does *~ mean?

At the end of a makefile I saw rm -f *~ *.class I understand the *.class, but what's *~?
9
votes
3answers
841 views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
9
votes
6answers
546 views

Is there a terminal app that allows filenames to be clickable?

Is there a terminal emulator (extension or app) that does link resolution for local paths? In particular when I see things like: ...
8
votes
2answers
2k views

What is the maximum allowed filename (and folder) size with eCryptfs?

I am a new eCryptfs user and I have a very basic question that I wasn't able to find anywhere. I am interested in using eCryptfs via my Synology NAS that uses Linux. While trying to encrypt my folder ...
8
votes
3answers
337 views

What are ./ and ../ directories?

Simple question, but I'm not sure where to look and google doesn't respond to periods and slashes. I'm just trying to count the # of files & directories in the current directory (not including ...
8
votes
2answers
1k views

why inode value changes when we edit in “vi” editor?

When I edit a file in "vi" editor the inode value of the file is changing. But when edited with cat command the inode value is not changing.
8
votes
1answer
146 views

Can I truncate long file names in ls listing

I have a number of files with very long names. Please, is there a way to use ls -C and truncate the file names to get more columns for an overall view? Or is there a better way to get a compact ...
8
votes
2answers
773 views

the slash (/) after a directory name on shell commands

I have a little question here. If I have two files, say filea and fileb, mv filea fileb would delete fileb rename filea to fileb Then if I have two directories, say dira and dirb, mv dira dirb ...
8
votes
3answers
98 views

POSIX compliant way to work with a list of filenames possibly with whitespace

I have seen Bash scripting guides suggesting the use of array for working with filenames containing whitespace. DashAsBinSh however suggests that arrays are not portable so I am looking for a POSIX ...
8
votes
1answer
190 views

Is there a way to prevent the creation of a given file?

When ever I use a browser reading PDF the acrobat plugin is used producing a file called C:\nppdf32Log\debuglog.txt in my home. Is there any way to prevent that this given file can be created? I mean ...
7
votes
3answers
414 views

Why do tar and gzip files usually have a file extension?

File extensions are not necessary on unices, still every tarred, gzipped or bzipped file I encounter has a file extension like .tar, .tar.gz or .tgz. Is there any special reason for that or is that ...
7
votes
4answers
532 views

How can I find a file whose name includes a given string, such as “abcde”?

Within a set of directories, how do I find a file whose name includes a given string, such as "abcde"?
7
votes
1answer
2k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
7
votes
3answers
234 views

Select unicode filename in Bash

Ok; suppose I'm in Bash and I have several files in a folder. Several of them are named file☠☡☢☣.txt, where ☠☡☢☣ starts with crazy untypable unicode characters. How would I refer to one of them? ...
7
votes
3answers
807 views

Change the color of the file name text

I am writing scripts to initialize and configure a large system with many components. Each component has its own log file. I would like to change the color of the component file name to red whenever ...
7
votes
2answers
2k views

How can you move (or copy) all files to a directory with the same filename prefix?

Using Bash So let's say I have a bunch of files randomly placed in a parent directory ~/src, I want to grab all the files matching a certain suffix and move (or copy) them to a ~/dist directory. ...
7
votes
3answers
401 views

Generate new name for moved file to prevent overwriting?

How can I generate a new name for a file if there's an existing file With that same name? In a Desktop environment a new name is generated my appending a number to the end of the file name, but how ...
7
votes
1answer
269 views

What is the significance of the dot in bash commands and how is it different from an asterisk?

I'm trying to understand the significance of the dot in bash and how it differs from an asterisk. Can someone please elaborate? For example, what's the difference between cp -ar /foo/. /foo2/ and cp ...
7
votes
2answers
2k views

Several questions about file-system character encoding on linux

Due to a lot of file exchange works between Windows (GBK encoding) and Linux (UTF-8 encoding), it will encounter character encoding issues easily, such as: zip/tar files whose name contains chinese ...
7
votes
1answer
177 views

Why do *nix filesystems support file names with newlines? [duplicate]

According to this page: File names in Linux can contain any characters other than (1) a forward slash ( / ), which is reserved for use as the name of the root directory (i.e., the directory that ...
7
votes
3answers
1k views

Is it possible to nest a 'find -exec' within another 'find -exec'?

Something like the following is what I what I'm after, but my code doesn't work, no matter how I escape {} and + ; find ./ -maxdepth 1 -type d -name '.*' -exec \ find {} -maxdepth 1 -type f ...
6
votes
3answers
420 views

Bash autocomplete gives different file name than ls

An incredibly strange thing just happened. Through a serious typo, I entered cp filename.xsl .^?~ Yeah, that's right, dot-caret-questionmark-tilde! Truth is stranger than fiction. It gets weirder. ...
6
votes
3answers
10k views

File extensions for unix shell scripts

On wikipedia, the article for .sh says: For the .sh file extension type, see Bourne shell. How about other unix shells? I know that the shebang is used inside the file to indicate an ...
6
votes
4answers
413 views

Files with empty names

I was writing a widget for displaying files in a given directory and I wondered whether I need to cover the case where a file has an empty name. Testing showed not obvious results, so I was ...
6
votes
2answers
1k views

UTF 8 filenames?

In unix based operating systems are utf6 filenames permissible? If so do I need to do anything special to write the file to disk. Let me explain what I'm hoping to do. I'm writing an application ...
6
votes
1answer
420 views

Why do some symbolic links affect program behavior?

One thing that has been puzzling me for some time is this: % which halt /sbin/halt % file /sbin/halt /sbin/halt: symbolic link to `reboot' However, executing sudo halt does, of course, not reboot ...
6
votes
3answers
137 views

How can I determine a file's conventional filename extension

The file command is good at determining file types for my needs. Is there any way to map those results to conventional filename extensions?
6
votes
3answers
2k views

adding text to filename before extension

I would like to add text to the end of filename but before the extension. Right now I am trying, for f in *.shp; do echo $f_poly; done the output is, Quercus_acutifolia.shp_poly ...
6
votes
3answers
2k views

File and directory naming conventions

I want to refactor the files and directories on my system. However I am not sure what is best practice. After reading this question and it's answers I assume the most important part is to be ...
6
votes
1answer
946 views

Best way to remove file extension from a string?

So, I'm using a script I've made to convert videos to the webm format. A certain program calls the script, sending %f which is the full, absolute file name of the video, like this: converter.sh %f ...