Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
1answer
16 views

How to use ext4 inline_data to store empty directories?

How can I use ext4's inline_data feature to store empty directories? It seems like inline_data works only with small files, or the directories store a lot of data.
0
votes
3answers
61 views

Recursively rename all the files without changing their extensions?

How to recursively rename all the files in several layers of subdirectories without changing their extensions? Below's a toned down version (to save room) of what I've got. For argument's sake, I ...
2
votes
2answers
30 views

trying to Rename multiple file names within all directories of a project

ive recently been trying to change the names around in my project and have been having some trouble getting the task done properly. my problem is when I try to use find . -type f -print0 | xargs -0 ...
1
vote
0answers
13 views

Maintaining file's SELinux labels when copying them from one directory into another

Default behavior for copying files or sub-dirs from one directory to another is that the copied objects do not maintain their SELinux type (domain) which is opposite to objects which were moved. ...
0
votes
1answer
38 views

Why “a lock file is the best approach if the resource is not a regular file, so using methods for locking files does not apply”?

Thanks to Mark's comment, pointing me to https://en.wikipedia.org/wiki/File_locking#Lock_files which says Shell scripts and other programs often use a strategy similar to the use of file locking: ...
2
votes
0answers
18 views

Do the filesystem under Linux enforce serialization, which means only one change to the filesystem actually happens at any given time?

https://unix.stackexchange.com/a/12818/674 says Lock files are used by programs to ensure two (well-behaved) separate instances of a program, which may be running concurrently on one system, ...
-1
votes
0answers
29 views

Why use “lock file” instead of a programmable lock? [duplicate]

Mark says at https://unix.stackexchange.com/a/467795/ One use for O_EXCL and O_CREAT with open() is to create a simple lock file. If multiple processes try to open the same file with the O_CREAT ...
0
votes
1answer
22 views

Open file in gedit by using full path

In the previous versions of gedit, I was able to open the file directly by entering the full path of file in open window dialog box. But now, I have to browse to the folder manually before I can open ...
0
votes
1answer
32 views

Solaris difference between 's' and 'l' in permissions

On a Solaris 11 machine, when I execute chmod 2000 myfile, I get l instead of S or s: touch myfile && chmod 2000 myfile && ls -l myfile ------l---. 1 pydoge pydoge 0 Oct 16 12:35 ...
0
votes
3answers
34 views

Replace space with Pipe between the tags

I have a file that is coming in tags "{}". Need to convert it into a pipe format. Here is the sample: {Id USXXXXXX} {Code USXXXXX} {Desc abcd 6.000% 5/24} Expected result 1: {Id|USXXXXXX} {Code|...
5
votes
7answers
1k views

One liner to check for file exists [duplicate]

Objective: Check for presence of backup .tgz file containing today's date; output 1 for OK, 0 for no file. I'm a sucker for one liners :) For example in PHP (and pretty much similar in Javascript), ...
-1
votes
1answer
40 views

What are two caveats of line buffering in Unix?

A paragraph from APUE Chapter 5.4 about line buffer: Line buffered. In this case, the standard I/O library performs I/O when a newline character is encountered on input or output. This allows us ...
0
votes
1answer
20 views

Tag files based on file name if no Title metadata exists

Is there a way using the command line to automatically fill in empty "Title" fields of the tags of music or videos with the file name? I have tried using Beets, but the only way to tag things based on ...
0
votes
2answers
31 views

How to check if first column's string of file1 exist in the file2?

I have two files, file1.txt contains strings separated by commas: 1.1.1.1,string1,comment1 7.7.7.7,string3,comment3 2.2.2.2,string2,comment2 88.88.88.88,string4,comment4 999.999,999,999,string5,...
-1
votes
3answers
39 views

Renaming files by the day they created

I have files I would like to rename it using the date they created. How can I do this automatically? Looking at the properties for every file then renaming it is a real pain. For example In a folder ...
3
votes
2answers
128 views

How do I print out the byte size of each file in my Bash script? [closed]

My current code is like so: scan.sh: #!/bin/bash while IFS= read -r line; do byte = $(stat -c%s "$line"); echo "$line : $byte"; done< <(ls *.$1) The output would be like this: ./scan....
0
votes
3answers
36 views

Grab the oldest 100 files out of thousands and zip them up but also create a listing of those files that I can cat out later

I was wondering if there is a way to grab the oldest 100 files from a directory that has a 1000 or more in it with the same prefix (cdr12345.csz, cdr32342.csv, cdr 98876.csv, etc..) and list the names ...
0
votes
1answer
14 views

How to preserve file mode with rsync, except for setuid bits?

I run into a "Disk quota exceeded (122)" error if I use rsync -p <args> to copy files around. rsync -rlptD --chown username:org1 -- local/ /project/org1/ I would like to preserve source read ...
0
votes
2answers
56 views

How to extract string between the first occurrence of : and a colon

I have a long file that I need to reprocess for entering it into database. The file's data are in this format: Error for: 111.222.55.1,[ZXX: Error message] some text (_xxx.c:833) Error for: 198.243....
2
votes
2answers
40 views

Error in deleting files or directories older than 1 day

I am able to delete files or directories older than 1 day using below command find /u01/Release/* -mtime +1 -exec rm -r {} \; but why I am getting error in the output of this command: ls -lrt ...
2
votes
2answers
45 views

Change all filenames in directory to numerals

I have files in a directory where filenames are like 01 ABC DEF.m4a 02 DEF ABC.m4a etc... I want to convert these to 1.m4a 2.m4a etc... How can I do this using the command line?
0
votes
1answer
59 views

Can't create files and directories

I am using Mint. Everything was fine until three days ago. I wanted to create a file but I discover that my external HDD has read-only mode (file system is NTFS). I didn't change anything before but ...
-1
votes
0answers
16 views

What's the difference between 'Last Access Time' and 'Last Modification Time' of a file? [duplicate]

Seeing these terms being used, not quite sure in what way they differ.. hope someone can explain.
1
vote
1answer
30 views

Creating empty copies of files with new extensions

I have AIX 7.1. Let's say I have a directory with files like these: 1.txt lala.csv I need to create empty copies of these files with a new extension in the same directory, like so: 1.txt.done lala....
0
votes
1answer
31 views

Add file (as attachment) to existing email

Is there a way to add a file to an existing email with mutt? It is an archived (i.e. old) email and I’d like to add a pdf to it for reference. Of course, it’s possible to forward / resend it to ...
0
votes
1answer
32 views

What does reusing the name of a file mean, for an immutable file?

Operating System Concepts says A unique approach is that of immutable shared files. Once a file is declared as shared by its creator, it cannot be modified. An immutable file has two key properties:...
-3
votes
1answer
27 views

Compare two text two files whilst one contains column with date [closed]

I have two text files, one of them contains: ... 2018-09-22 FFF1B976-9DDE-11E7-9C3D-6241D7D553BE 2018-09-27 682D9DB6-C0A2-11E8-B7A8-3ECB9C0CC049 2018-09-27 682D9DB6-C0A2-11E8-B7A8-3ECB9C0CC049....
0
votes
1answer
39 views

Is it possible to list all files that are opened by a process [duplicate]

I know that lsof can list all files which are being opened by running processes. If there is a process, which will open a file and then will be terminated, I don't think I can catch the file that is ...
5
votes
3answers
652 views

Opening most recently modified file in vim

The following commands work $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt But this does not $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim:...
2
votes
3answers
42 views

Conditionally replace lines of file1 with the corresponding lines of file2

For example, I have two files: file1: 1 4 X 5 X 7 file2: 2 3 5 X X 1 I want to replace X-lines of file1 with whatever is in file2 on the corresponding line: result: 1 4 5 5 X 7 I prefer the ...
1
vote
3answers
85 views

type ls command [duplicate]

so i studied somewhere about the type command and came to know that type command can provide the location of command used with it,more specifically the location of the executable file associated with ...
0
votes
1answer
20 views

How can a syslog configuration be set to place a log in the users home directory?

I want to use one of Drupal's syslog modules but place the log in a the user's home directory so there are not permissions issues when the user wants to view or analyze the file. Is there a way a ...
1
vote
2answers
68 views

Find a list of files that contains a set of consecutive lines defined in another file

I have a Reference file that contains a b c d I have to check all files in a subfolder recursively that contains all the lines of Reference file consecutively and delete those files. For example, ...
2
votes
3answers
78 views

CLI equivalent of Gnome's recent files feature

In Gnome's File manager (Nautilus), there's a feature called "Recent Files" which presents itself like a "virtual directory" of sorts, listing the most recently created/modified files in the user's ...
0
votes
1answer
53 views

is it safe to delete ~/home/{User}/.cache/ [duplicate]

I think the title sums it up. IF it's cache it is probably meant to be cleared eventually, but can I just manually delete the whole .cache folder? It's eating over 10 gigabytes on a 64 GB partition. ...
0
votes
1answer
81 views

CentOS Server file permissions

I am starting to learn server management with a CentOS Virtual Machine. I am trying to make a simple website. Because the Apache default file is in /var/www it is hard to write/make/change files. ...
0
votes
2answers
22 views

Find + paste + find: do multiple queries to each file

I am trying to get for each file in a directory, a row with at least, the following fields (the order doesn't matter, although that one is the preferable): - Image resolution, in case it is an image....
0
votes
1answer
41 views

Removing files containing, only, one row? [duplicate]

I have large number of csv files saved within a folder. I would like to, only, delete the csv files that contains one row, how can I do that?
0
votes
0answers
5 views

Squid Proxy acl file size

I have squid Proxy server in Centos 7 & there machine configuration is RAM :- 8 GB processor :- Intel xeon CPU E31245 @ 3.30 GHz. I put the 50 MB Blocklist ACL file in /etc/squid/blocked.domains....
0
votes
1answer
37 views

Linux Mint - add file type to “new file” context menu category

I am trying to add a new file extension to cinnamon's new file menu right click create new document I would like to add entries in this list I remember that I have done this before based on a ...
0
votes
2answers
37 views

How do you find the path of a directory that contains one file but don't contain another file?

Right now my approach is to: find directories containing a.txt find -type f -iname "a.txt" | sed -r 's|/[^/]+$||' > a_paths.txt find directories containing b.txt find -type f -iname b.txt | ...
1
vote
1answer
33 views

Filesystem design: necessity of inode number and table [closed]

The *nix filesystems maintain an inode table at the beginning of the disk (or at some fixed location). It is indexed by the inode number, which is an integer that uniquely identifies an inode. Knowing ...
-1
votes
2answers
35 views

Restoring files names using md5 file

I recovered some files from my HDD, but there names were changed. Also, I found md5 files of the recovered files. How can I use the md5 file to restore files names?
1
vote
1answer
31 views

free -m: free size reduced because of cache/buff

I'm using the function rosbag of ROS. rosbag can record lots of data from other ROS nodes. In a word, it will generate a huge file, such as a file of 200MB. After generating such a file, I found that ...
2
votes
2answers
63 views

MacOS: What file does the command `last` get its information from?

Can't seem to find where this last command gets its information from. Does anyone know what file it uses (specifically for Unix macOS) ? Tried cat /var/log/wtmp, cat /var/run/utmp, cat /var/log/...
0
votes
1answer
29 views

Changing the the view of applications and users on the filesystem?

Is there any way to change what files (in particular files content) an application can see? I know you can prevent access to files with DAC or MAC, but I don't want to prevent accessing. Instead, I ...
0
votes
1answer
42 views

How do I create loops to join groups of files within a directory?

I have lots of very large files that take a long time to join manually. They look something like this: file_a1.txt file_a2.txt file_a3.txt file_b1.txt file_b2.txt file_b3.txt file_c1.txt file_c2.txt ...
4
votes
2answers
350 views

How to delete files created between two times?

I have a folder where I backup my databases to and I want to delete all backups created between 11 am and 3 pm and it doesn't matter what day it is -- this is the catch! I found this command to be ...
0
votes
1answer
17 views

List files exceeding a certain size limit

I have an application structured in the form of a folder and several levels of subfolders. I want to list all the files within my application's folder that are equal to or larger than 300KiB. How do ...
2
votes
2answers
161 views

How to intercept temporary files created by a program? [duplicate]

TL;DR: I know a program creates and then deletes files in /tmp. How can I intercept them for examination ? Context: There's a particular .jar file, which I don't trust; for some reason its source ...