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

learn more… | top users | synonyms

5
votes
1answer
2k 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: ...
1
vote
3answers
2k views

Script to show number of files (by file type) in a directory?

I want to show this kind of statistics about a particular directory: $ myscript.sh .c 34265 files .h 17866 files .cbl 1804 files .pco 389 files [...] Is there a tool that can do this? Here is my ...
2
votes
3answers
177 views

Selecting latest files and grouping by name

I have a directory containing files of the following name structure. <device>.<yyyy-mm-dd-hh-mm-ss> I am working on a script that will retain the the last X copies of these ...
9
votes
3answers
13k 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 ...
7
votes
2answers
3k 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. ...
3
votes
1answer
563 views

Export a m3u playlist to a directory in order they appear in the playlist

There is a way to rsync a m3u playlist into a destination directory. How can I process the list and number the output so it orders the files to match the playlist order? For example the m3u: ...
4
votes
2answers
1k views

Trailing slashes on symbolic links to directories

I'm trying to emulate the process of path resolution (see man page path_resolution) in unix-like systems. My OS is Linux with GNU coreutils 8.7. In order to clarify the meaning of extra trailing '/' ...
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 ...
4
votes
1answer
822 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
361 views

What is the file-naming convention for regular text files?

For regular *.txt text files that contain documentation and notes and such, and which are not READMEs, is there a Unix convention for naming them? Namely, Should the filenames be all lowercase? ...
4
votes
3answers
6k views

Running python script from terminal without .py extension

I want to call a python script script.py from the terminal by simply typing script. Is this possible? If so, how? I know I can avoid typing python script.py by adding #!/usr/bin/env python to the top ...
1
vote
4answers
885 views

Strange directory name, shown with a backslash

I have copied and pasted a directory of files into another. The result is now this one development\ / I do not know what that means? Linux does not even recognize it as a directory now. Also the ...
3
votes
2answers
591 views

Renaming files in lexicographical order with a numerical pattern that increases sequentially with fixed padding

I have files such as a bb ccc abc emrls I would like to rename them so that, after sorting them (for example, lexicographically), each file gets the following name: 00001 00002 00003 etc where ...
5
votes
3answers
2k views

How store in a variable a file list that includes the backslash when needed?

Main question: I am writing a script to perform a backup. I make a list of files in the following way: LISTOFFILES=$(find ~ \( -name '*.[pP][dD][fF]' -o -name '*.[oO][dD][tT]' \)) The variable ...
4
votes
1answer
201 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/, ... ...
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 ...
4
votes
2answers
189 views

Emacs' file extension recognition

How do I get Emacs to recognize new file extensions? For example if I have a .c file and I open it in Emacs, I get the correct syntax highlighting for C, but if I have a .bob file format (which I know ...
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. ...
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?
2
votes
3answers
2k views

create md5 hash from a recursive file listing when some paths have spaces

I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path. I am ...
14
votes
3answers
729 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 ...
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
4answers
509 views

Find files without a number

I am trying to write a simple script that will iterate through all drives except sda. Right now I have this for i in $(find /dev/ -name "sd*" ! -name "sda*") do echo $i done However this ...
2
votes
2answers
444 views

Script to prepend the files path to a file recursively

I work as a grader and files submitted to me end up in a folder named with the student's name which is itself inside a specific folder on my linux share. Currently I go through each source file and ...
5
votes
2answers
3k views

special character in filename (\#033OA)

I've got a slight problem with a very stubborn error during an rsync. It's caused by a file with a special character in its filename. There's been others but I could sort that out by doing some ...
1
vote
1answer
2k views

How can I specify that curl (via command line) overwrites a file if it already exists?

I'm using curl in this syntax: curl -o myfile.jpg http://mysite.com/myfile.jpg If I run this command twice, I get two files: myfile.jpg myfile-1.jpg How can I tell CURL that I want it to ...
3
votes
2answers
182 views

filename with no spaces from two command lines

I am running two Linux commands and I want to put the resulting values together in a filename with no spaces and a dot separating the two values. So far, I've got this: pid=`sudo dmidecode -s ...
2
votes
2answers
8k views

Bash shell script to locate and remove substring within a filename

I am trying to write a bash shell script in Mac OS X 10.6 (which is called by an Automator Action) to rename TV show DVD rips that I have named badly over the years. I want to remove part of the text ...
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 ...
6
votes
2answers
839 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
3answers
2k 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 ...
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 ...
1
vote
1answer
720 views

Do special characters in paths pose a problem when mounting network shares?

I am trying to create a permanant access point to a windows share from a CentOS 5.5 machine. I edited the /etc/fstab file to have the following entry: //travellot/ArcGIS Setup's/9.3.1 ...
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"?
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
1answer
786 views

shopt -s nocaseglob is not working on Ubuntu

Case insensitive file name globbing is not working in bash on Ubuntu 11.04 64bit. The shell options specified in .bashrc are as follows: shopt -s nocaseglob shopt -s nocasematch shopt also shows ...
10
votes
6answers
30k 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 ...
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
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 ...
0
votes
0answers
41 views

How to change ALL the postfixes of files in a single directory, single command [duplicate]

Possible Duplicate: How to clean up file extensions? have a directory full of files ending with .JPG I need to change them all to .jpg How?
3
votes
6answers
1k views

finding the absolute directory

Here is the scenario: foo/ > data/ > stuff/ > scripts/ -> /.../generic/scripts When calling foo/scripts/bar.sh from any location (other folder or inside the folder), I would like to be ...
2
votes
1answer
241 views

rm command returns a message [1] 12345 What does this mean?

I'm trying to remove a file and I keep getting a message similar to: [1] 12345 and nothing happens, I run a directory search (dir) and the file remains and I get a stopped message
5
votes
5answers
463 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?
3
votes
2answers
173 views

returning strings corresponding to shell glob matching

Suppose I have a subdirectory called sub. Then I want to operate on all files in that directory with the extension "txt". I want something like for f in sub/*.txt do enscript -b "" -o {$f ...
5
votes
2answers
71 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
3answers
4k 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: ...
2
votes
2answers
226 views

Should all plain text files have some sort of suffix (e.g. *.txt, *.conf) [closed]

I create many notes in plain text files, but after a while the .txt suffix I put at the end of them seems to be unnecessary typing and visual noise. Is appending .txt to plain text files a strongly ...
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 ...
4
votes
3answers
6k views

How to add unique id to file name in cron job?

My cronjob looks like this: 5 3 * * * mysqldump -u root test > /srv/backup/mysql_daily.dump How can I make filename unique for every time when cronjob writes mysql_daily.dump?
3
votes
1answer
2k views

rsync: colon in file names

Other than by renaming the files first, how can I rsync files that may have colons in their names?