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 ...
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 ...
6
votes
1answer
945 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 ...
2
votes
2answers
287 views

Script to convert filenames to lowercase depending on extension

Script to convert filenames to lowercase depending on extension
2
votes
1answer
1k views

Rename All Files with a Certain Name

I'm trying to find certain files with the name "stringx" and replace the name (but not the extension) with "stringy". So basically for stringx.txt and stingx.cs, I'd want stringy.txt and stringy.cs. ...
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: ...
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 ...
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 ...
14
votes
3answers
596 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 ...
13
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, ...
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 ...
13
votes
3answers
2k 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 / ...
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 ...
4
votes
1answer
701 views

Autocomplete of filename in directory

This question is quite similar to this one, but I can't understand the solution. I also know this tutorial, but still I am unable to understand what I am doing wrong. I am trying to autocomplete the ...
3
votes
2answers
342 views

Is there a user interface in Emacs allowing one to “grab” the buffer's filename conveniently?

It happens quite often that I want to use the path of the file opened in a certain buffer in Emacs (either the full path or the basename) in another place (a buffer or a different X program, say, a ...
2
votes
3answers
1k views

Manipulate file name piped from find command

I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
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"?
6
votes
2answers
1k views

working with filenames in a different encoding over ssh

I'm ssh'ing to a remote system where a different encoding for the filenames (and for the users' locales) has been used. And this causes some problems. Problems solved by matching the locale settings ...
1
vote
1answer
155 views

Trouble with mv and adding the date

I want to be able to move $oldfile to my backup folder and add the date to the file name. So I tried this... mv $oldfile /home/u0146121/backupfiles/$oldfile_$(date +%F-%T) This just gives me this ...
-4
votes
1answer
63 views

How to copy datasets from prior version directory to latest version directory [closed]

I've go a number of directories named like: /data/db/OX/8_10 /data/db/OX/9_1 /data/db/OX/9_2 And need to copy some files (all the pt.* files) from the second latest one (above 9_1) to the latest ...
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?
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 ...
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 ...
12
votes
2answers
268 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 .* ...
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 *~?
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
2answers
772 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 ...
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 ...
4
votes
6answers
2k views

cat files with directory

Is there a command to show the directory/file name when cat files? For example: assume two files f1.txt and f2.txt are under ./tmp ./tmp/f1.txt ./tmp/f2.txt Then when I do cat ./tmp/*.txt, only ...
4
votes
4answers
508 views

Good style/practices for separators in file (or directory) names [closed]

I'm not exactly sure if this is a "right" question to post here. I'm probably asking more about "opinions" than actual categorical answers (of those that either work or don't, and that's it). I was ...
1
vote
3answers
194 views

fsck -cc /dev/sdb1 gives this result. Is everything okay?

root@host [/]# fsck -cc /dev/sdb1 fsck from util-linux-ng 2.17.2 e2fsck 1.41.12 (17-May-2010) Checking for bad blocks (non-destructive read-write test) Testing with random pattern: done /dev/sdb1: ...
5
votes
3answers
121 views

Filtering redundant paths from a list of paths

I have a list of relative paths such as this: dir1 dir2 dir2/dir3 dir2/file1 dir3/file2 dir3/dir4 dir3/dir4/file3 In the example above, the specifier dir2/file1 (for example) is redundant, because ...
5
votes
5answers
438 views

How do I remove a file I accidentally created named $file?

I was working on a shell script and I accidentally created a file with the variable as its name. Now I have $file in my ls output, and cannot remove it. What can I do?
4
votes
2answers
737 views

file descriptor vs. file name

I was wondering what differences and relations are between file descriptors and file names. Are they all used to access files? If yes, in the same way? For example, /dev/fd/0, /dev/stdin, and ...
4
votes
0answers
270 views

Why is there a '.d' in 'init.d'? [duplicate]

Possible Duplicate: What does the .d stand for in directory names? Consider that we have (on many sytems) init.d that contains executable scripts and symbolic links for run levels, sysctl.d ...
3
votes
1answer
60 views

Test for link with trailing slash?

I created in /tmp/test/ mkdir somedir ln -s somedir/ somelink I want to loop through only directories: for file in */ ; do if [[ -d "$file" && ! -L "$file" ]]; then echo "$file is a ...
2
votes
4answers
3k views

How can I find all files in a folder that contain a match of a regular expression in the file name?

I'd like to find all of the files in my home folder on Linux (Ubuntu, in this case) that contain a match a particular regular expression. Is there a simple Unix command that I can use in order to do ...
0
votes
2answers
131 views

file command + how to view all results from file command

I use the file command in order to verify if file (PATH) is text/ascii file or encrypted file Because file command have allot of results ( small example in example 1 ) I want to get the all ...