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

learn more… | top users | synonyms

44
votes
6answers
5k 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 ...
34
votes
8answers
43k 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 ...
3
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. ...
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 *~?
30
votes
4answers
3k 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
1k 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 ...
7
votes
4answers
542 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"?
2
votes
2answers
329 views

Script to convert filenames to lowercase depending on extension

Script to convert filenames to lowercase depending on extension
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: ...
14
votes
7answers
7k 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 ...
14
votes
3answers
3k 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
736 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 ...
2
votes
2answers
1k views

What does the tilde (~) mean at the end of a filename? [duplicate]

What is the file with the ~ at the end of the filename for? $ ls # aliased to add flags -rwxrwxr-x 1 durrantm 2741 May 16 09:28 strip_out_rspec_prep_cmds.sh~* drwxrwxr-x 13 durrantm 4096 May 16 ...
15
votes
6answers
13k 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 ...
15
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 / ...
7
votes
2answers
3k 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 ...
6
votes
2answers
844 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
1answer
832 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
364 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
2k 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 ...
0
votes
6answers
1k views

File extensions and association with programs in linux

In windows we can associate a file's extension with programs. E.g. a file test.pl can be run by the installed Perl interpreter due to the pl extension. In linux though it needs #!/usr/bin/perl as the ...
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 ...
3
votes
6answers
266 views

How to delete a NTFS filesystem file whose name contains “:”?

I backup some of my Linux files in a NTFS removable hard disk several days ago, this time I need to remove those files. But I find it difficult since: On windows, it complains that "Could not find ...
3
votes
3answers
2k views

Bash script that reads filenames from a pipe or from command line args?

I want my script to read a bunch of filenames (which may have spaces) given either as a glob or from STDIN and do stuff with them. I've been able to read either way separately, but not combine them. ...
1
vote
1answer
208 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
64 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 ...
17
votes
3answers
10k 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 ...
14
votes
4answers
9k 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?
21
votes
10answers
7k 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
409 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
31k 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 ...
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
802 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
3k 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
1answer
68 views

mapping a split file to /dev/loop0

I have a iscsi disk 2TB large. I make backup of that disk every week. The backup script copies the image of the whole iscsi disk into a file on my NFS. Unfortunately, it does not copy the image in one ...
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
644 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
395 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
132 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
466 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
0answers
274 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
3answers
133 views

filename and pathname of a file

It is said that the filename of a file is a pointer pointing to the inode of the file. Before knowing that, I thought it was the pathname of a file that does that job. I am not sure how a pathname ...
3
votes
1answer
86 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 ...
3
votes
2answers
432 views

Why are filenames that start with a dot hidden? Can I hide files without using a dot as their first character?

Initially I thought it was a coincidence, but now I see there's even a tag for it: all hidden file names start with a dot. Is this a convention? Why was it chosen? Can it be changed? Or in other words ...
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 ...
1
vote
1answer
108 views

cp /etc/DIR_COLORS ~/.dir_colors not responding

I'm using CentOS 6.5 and Putty. My problem is that directory file names are shown in dark blue color which is hard to read. I google searched and found this link; basically it's copying the DIR_COLORS ...
0
votes
2answers
148 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 ...