The filenames tag has no wiki summary.
34
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
6answers
3k 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 ...
22
votes
4answers
1k 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 ...
20
votes
2answers
2k 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?
18
votes
9answers
2k 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 ...
17
votes
7answers
22k 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 ...
13
votes
9answers
4k 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 ...
13
votes
3answers
6k 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 ...
13
votes
3answers
3k 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
8k 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, ...
11
votes
4answers
4k 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?
10
votes
1answer
1k views
What does *~ mean?
At the end of a makefile I saw
rm -f *~ *.class
I understand the *.class, but what's *~?
10
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 ...
9
votes
3answers
951 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 / ...
8
votes
4answers
12k 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
250 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 ...
8
votes
6answers
323 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
715 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
1answer
136 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
6answers
2k 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
...
7
votes
3answers
385 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
478 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
1k 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
269 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 ...
7
votes
3answers
503 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
667 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.
7
votes
2answers
961 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
1answer
143 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
1k 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
3answers
322 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
1answer
350 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
1k 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
3answers
669 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 ...
5
votes
3answers
180 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 ...
5
votes
2answers
541 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 ...
5
votes
2answers
156 views
How to put the specific files from a directory in an array in bash?
Suppose I have a directory under which there are 3 files named: file1.txt,file2.txt and file3.txt.
Now how can I fill an array with those file names(I just know that all the files have certain ...
5
votes
1answer
668 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
...
5
votes
3answers
352 views
Glob with Numerical Order
I have this list of pdf files in a directory:
c0.pdf c12.pdf c15.pdf c18.pdf c20.pdf c4.pdf c7.pdf
c10.pdf c13.pdf c16.pdf c19.pdf c2.pdf c5.pdf c8.pdf
c11.pdf c14.pdf c17.pdf c1.pdf ...
5
votes
1answer
969 views
Cannot open: Input/output error with tar command in a shell script
I am trying to create a tar ball in a shell script (I have enabled set -x), but I get an error:
+ cd /home5/mysite/public_html
+ TAR_DUMP=gypo_2012-02-18-03:51:15.tar.gz
+ echo 'Tar name: ...
5
votes
3answers
87 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
2answers
724 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
...
5
votes
1answer
123 views
Can non-canonicalized forms of filesystem paths be significant? (eg. “foo//bar”, “foo/./bar”, and “foo/../bar”)
I have a script for building a particular flavor of GCC cross-compiler. Throughout the script there are many paths that are not in canonical form, such as duplicate path separators (/xxx/foo//bar/yyy) ...
4
votes
3answers
329 views
How do I delete a file named “°” in bash
I've accidentally created a file named °. Now I'm having trouble deleting it with bash.
[/opt/etc/sudoers.d] # ls -l
-r--r----- 1 admin administ 21 Feb 3 23:54 010-root
-rw-r--r-- 1 ...
4
votes
4answers
270 views
Good style/practices for separators in file (or directory) names
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 ...
4
votes
2answers
65 views
Making a duplicate of a path in Unix
My Unix vocabulary is failing me. I have 5 billion images in /foo/live/images.
For the purposes of developing a new version of the app I'd like to make /foo/dev/images into a working path without ...
4
votes
1answer
183 views
What's the name of the top-level directory
I am using Ubuntu.
I know by using cd ~/ , I can go to home/ directory.
But if I want to go to the directory (I do not know the official name of this directory) which contains etc/, var/, opt/, ... ...
4
votes
3answers
2k views
How to find files in subdirs and sort them by filename in a single command?
Result of a normal find using find . ! -path "./build*" -name "*.txt":
./tool/001-sub.txt
./tool/000-main.txt
./zo/001-int.txt
./zo/id/002-and.txt
./as/002-mod.txt
and when sorted with sort -n:
...
4
votes
3answers
1k views
How do I move some but not all files from one directory to another?
I need to move my files from one directory to other. But there is some issues. My file name pattern is like:
apple.0, apple.<n>, n -> {0,1,2,3 ...~ }
so mv apple.* will not work, because ...
4
votes
4answers
614 views
Replace dots with underscores in filenames, leaving extension intact
I have a bash script which I'm trying to get to replace dots in filenames and replace them with underscores, leaving the extension intact (I'm on Centos 6 btw). As you can see from the output below, ...
4
votes
3answers
4k 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 ...
