Questions tagged [files]

Manipulating files: copying, renaming, searching, analyzing, archiving, etc. For operating on text in a file, see /text-processing. For questions about the Files file manager (formerly Nautilus), see /nautilus.

A computer file is a logical entity that resides in a filesystem and is either empty or contains data. Depending on the filesystem, files have certain attributes, such as: (full) path, name, permissions, size, etc. Files are typically arranged in a set of folders or directories to separate them by purpose.

For the Gnome file manager Files, formerly known as Nautilus, see .


We have a canonical question with several good examples that asks:

How can I replace a string in a file(s)?


There are many tags on this site that are related to files; use these either along-side or in place of the files tag:

  • - either generically renaming files or the prename (perl rename) utility
  • - a utility to find files
  • - who can read, write, and execute a file
  • - logical container for a set of files
  • - contains files and directories on a storage device
  • - lists files and their attributes
  • - removes a file
  • - renames one or more files
  • - special syntax for a shell to specify more than one file, using a pattern
  • - special link to another file
  • - files that contain messages from one or more programs
  • - name of a file
  • - copying files from one place to another (e.g. cp, rsync, dd)

There are other tags on this site that deal with the processing of the data in files; use them in place of this tag:

  • - performing some operation (modifying, adding, deleting) on text in a file
  • - presenting the text in a file in a different way
4986 questions
83
votes
2 answers

What does dead.letter files do

I find dead.letter files from time to time in my $HOME directory. What they are for?
67
votes
10 answers

Is there a file that will always not exist?

Along the lines of /dev/null (path to an empty source/sink file), is there a path that will never point to a valid file on at least Linux? This is mostly for testing purposes of some scripts I'm writing, and I don't want to just delete or move a…
user304684
32
votes
3 answers

What happens when you read a file while it is overwritten?

Suppose I read (cat) a file while another process is rewriting its contents. Is the output predictable? What would happen?
Leven
  • 445
30
votes
8 answers

How can I trick a process into thinking a file doesn't exist?

I have a program that stores its settings in ~/.config/myprogram that I use both interactively and with a batch queuing system. When running interactively, I want this program to use my configuration files (and it does). But when running in batch…
29
votes
3 answers

How do I remove multiple files with a common prefix and suffix?

I have many files named sequence_1_0001.jpg sequence_1_0002.jpg sequence_1_0003.jpg ... and files named sequence_1_0001.hmf sequence_1_0002.hmf sequence_1_0003.hmf ... and files named sequence_2_0001.jpg sequence_2_0002.jpg …
Paul
  • 9,423
22
votes
3 answers

What's the last character in a file?

I just read the answers to Removing a newline character at the end of a file and everyone said to delete the last character. My question is, isn't the eof character the last one?
sworwitz
  • 273
17
votes
2 answers

How do I append text to a write protected file

Possible Duplicate: Redirecting stdout to a file you don't have write permission on I am trying to append a line of text to a write protected file. I tried to accomplish this with sudo echo "New line to write" >> file.txt but I get a permission…
Toby
  • 3,993
17
votes
3 answers

What is the difference between binary file and .exe file?

Can anyone distinguish the difference between binary file and .exe file?
user2720323
  • 3,589
11
votes
7 answers

Find files older than X days and output them by their size

I am trying to get the files older than a number of days and list them in descending order based on their size with all their information (size, full path etc - something similar that is provided by ls). While I am able to locate files older with:…
7
votes
7 answers

Sum total bytes of files

If I have files a, b and c in a directory on a Linux machine. How can I get the total number of bytes of these 3 files in a way that does not depend on how e.g. ls shows the information? I mean I am interested in a way that is not error prone …
Jim
  • 10,120
7
votes
1 answer

Have a 'file' generate its content on demand?

Is there a way that I can have something which appears as a file, but when being read some code executes which fills the content of the file "on the fly"? Like FIFO/ named pipe, but without the need to start the writing process by hand. Or like CGI…
7
votes
1 answer

Normal looking text file, detected by file as ASCII Pascal program text

I have a "normal" looking text file (contains english sentences) which is getting detected by file command as ASCII Pascal program text. How does Pascal program text differentiate itself from normal ASCII English text? I did head -10 file >…
user13107
  • 5,335
6
votes
1 answer

What are the metrics that `file ` uses to determine the type of a text-like file?

I have a bunch of LaTeX source files, all have the same structure, all have Unix-style line endings and all are UTF-8, all are roughly the same size (1-2KB), all use spaces for indentation-formatting. They are included in a bigger document, each…
Jack
  • 171
5
votes
2 answers

list size of folders and their changed date

How can I list the size of folders as well as their changed date? I am able to get the size of folders using du. I am also able to list the folders together with their date using $ls -ltr $path | grep '^d' But I cannot display the size and the…
5
votes
1 answer

Deleted folder keeps coming back

I have a directory at /opt/splunk that I cannot seem to get rid of. root@alpha:/opt# ls -la total 87156 drwxr-xr-x 4 root root 4096 Feb 20 15:44 . drwxr-xr-x 23 root root 4096 Feb 19 13:29 .. drwxrwxrwx 3 root root 4096 Feb 20 15:23…
Rip Leeb
  • 347
1
2 3 4 5 6 7 8