Use this tag for questions about file management and operations on files.

learn more… | top users | synonyms (1)

5
votes
2answers
74 views

How can I list files of which no symlinks exist?

I have a large "myfiles"directory full of miscellanous documents and do not want to modify its structure. I therefore created (several) other directories for each class of documents. For example I ...
2
votes
2answers
56 views

Print file contents and delete the printed content* from the file

In Linux, from a bash shell, how can I print the contents of a file and remove the content I just printed content from the file? I have a program writing texts to a file repeatedly. On a Linux shell ...
2
votes
4answers
44 views

Does the inode change when renaming or moving a file?

in PHP the fileinode() functions returns the inode of a file. I was wondering if I can use it to determine if a file was renamed, moved or modified. I did some tests and it seems the inode stays the ...
5
votes
6answers
69 views

Exclude directories with locate search

A search with locate finds paths in the filesystem. Often, you know a priori you are interested in either files only, or directories only. A 'locate' search often returns many results. It would be ...
2
votes
4answers
46 views

input file stream to command

How is it possible to send a file stream to this command instead of a file? /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q $SOURCEFILE $OUTPUTFILE The file stream is from a string in PHP.
2
votes
3answers
35 views

Can a file be edited with the 'write' permission on it but not on its parent directory?

Suppose the owner/user doesn't have the write permission on a directory but he has it on a file under it. Can the file here be edited or not? If yes, is there any situation where the file cannot be ...
0
votes
0answers
34 views

Touch a file and give it an icon image via command line

Imagine this situation: for a given task, at some point of it, I should be able to create an empty file, which I can achieve by touch file.ext on the command line. However, if I touch a .jpg file, and ...
0
votes
1answer
41 views

Search a file for a string in multiple directories

Can someone please help me with a command to search a file for a string in multiple directories? I am searching for the VIP in httpd.conf in multiple httpd instances. I am using: find ./ -name ...
1
vote
1answer
28 views

Can I restrict sudoer nopasswd to directory?

Maybe I should rephrase - what is the most secure way to accomplish my needs? Details I am using WinSCP to modify my Apache document_root. The directory /var/www/html has an owner and group of root. ...
0
votes
0answers
24 views

backup without closing programs that are opening files for editing, and detect unsaved open files?

Is it possible to do backup without closing programs that are opening files for editing? I would like to do backup without closing programs that are opening files that I am reading or writing. I ...
0
votes
0answers
23 views

Cancel removing a directory, and want to find out what have been removed

I was removing a directory by rm -r mydir and cancelled it in the middle. How can I find out what have been removed under the directory? Does remove a content of a directory change the timestamp of ...
2
votes
2answers
53 views

vim: how to trace back all changes done to file during the day

Does anybody know how to setup vim (the text editor) in such a way to make it possible to trace back all the changes done to a file within a day? I need it for the cases when I have accidentially ...
0
votes
1answer
27 views

Unable to delete a file on different user's directory

I've two user's abc & xyz and the user abc has been added to the group xyz via usermod -a -G xyz abc and here the file permission on home directory of xyz i.e /home/xyz: drwxrwxr-x 2 xyz xyz ...
-1
votes
0answers
41 views

No Such file or Directory 4 [on hold]

throw the script posted in this question link syntax error near unexpected token `)' I get this error: test.txt: No such file or directory 140308719470240:error:02001002:system library:fopen:No ...
1
vote
1answer
34 views

Difference between owner/root and RUID/EUID

I am relatively new to the concepts mentioned in the question and reading about them from different sources only makes them more confusing. So this is what I understood so far: When we are given ...
4
votes
1answer
40 views

Recovering data written to file that moved

I have a Python daemon running on CentOS that opens a file at the beginning of a session, and keeps writing to it. A cronjob however, gzipped the file that was being written to, and so the file moved ...
3
votes
2answers
57 views

How to list files on terminal so that we can see the file types such executable, ascii etc?

I have been trying to list files in directory using ls and passing it different options. Does it have the ability to list types of files as well ? I want to know which ones are executable , ...
2
votes
1answer
30 views

Why am I seeing a number as owner / group instead a name?

CentOS 6.x / OpenVZ Recently my VPS provider moved my OpenVZ container to a new server. After that move, I've noticed that files/directories for one of my user accounts show an odd owner / group. ...
1
vote
1answer
22 views

How to determine the only additional file in otherwise two identical listings?

I have done a listing of the device folder two times, one time without the sd-card in the slot and one time inserted, the system automatically adds one file in the device folder. $ ls /dev | wc -l ...
2
votes
1answer
40 views

How to change only the mtime of a directory?

I am trying to change just the mtime of a directory by adding files or sub directories but that changes the ctime of the file too. Is there any way to just change the mtime without affecting the ctime ...
1
vote
0answers
14 views

How to move directories based on the output of rhash (CRC32 check of .sfv) with bash/perl?

My idea, is to move the CRC-check OK folders (albums) into a lets say "complete+CRC_OK" folder with a script once per day in cron. I would need to put the rhash command in a loop with number of ...
0
votes
0answers
37 views

How can I let a application/user account only create and update a log file (no read permissions) in Linux

I'm attempting to setup a fairly restrictive Apache Tomcat installation on CentOS 6.6 and am stuck on file permissions for the log folder. The tomcat folder and all it's sub-directories are owned by ...
2
votes
2answers
41 views

How does one permissibly access files on non-booted system's user's home folder?

I have a dual boot system with Mint 17.1 and Centos 6.6 I want to access a file in my CentOS user's home directory from Mint. (I cannot boot CentOS right now.) What is a clean/standard method for ...
2
votes
3answers
42 views

Set group permissions as owner permissions

I need to set the same permissions of owner to group recursively to all elements in a directory.
1
vote
0answers
46 views

How to move /usr folder and replace it with saved copy [duplicate]

If I made a backup of /usr with: # cp -r /usr /usrRESERVE1 how can i switch it back after some time: 1# mv usr usrRESERVE2 2# mv usrRESERVE1 usr second command will not work because mv is inside ...
0
votes
0answers
54 views

All my files from my /home/[username] directory are deleted…sometimes

After random boots, and without warning, all my files are deleted from my home directory. This includes folders, but strangely, doesn't include hidden files/folders (it's as if someone ran rm -rf ...
3
votes
2answers
68 views

save the number of files only in a specific folder

I'm using this script to save the number of files in a main folder, but it also counts the subfolders inside that main folder. nfiles=$(ls -1 /home/userA/mainfolder | wc -l) Any advice how I can ...
1
vote
2answers
34 views

How to copy only files in a specified directory to another folder

I'm trying to copy only the files from one directory (not including folders or any files in its subfolders) to another location using cp /media/d/folder1/* /home/userA/folder2/. It is copying the ...
0
votes
0answers
61 views

Why is moving file within an ext4 partition so slow?

The short question is why is a move operation, moving within the same ext4 partition taking longer than a copy of the same files from a different drive? The longer description of the scenario: I ...
1
vote
1answer
32 views

How to test whether a file is a font file

I have several thousands of automatically saved web-pages, proceeding from different sources. Many of the web-pages have embedded fonts in files like *.woff, *.eot, *.ttf, and *.svg. I'd like to ...
1
vote
1answer
82 views

Reading the contents of an ELF file (programmatically) [closed]

I am trying to retrieve the contents of an additional section within an ELF binary. At this point, I'm using the following code to retrieve the name of each section: #include <stdio.h> #include ...
2
votes
0answers
30 views

How to sort files by their dates into timestamped folders? [duplicate]

I want to sort about 2500 images every day into folders with a timestamp. So far I have this script but it's not working.... for x in *.jpg; do d=$(date -r "$x" +%Y-%m-%d) mkdir -p "$d" mv -- "$x" ...
1
vote
4answers
62 views

Delete all files in a directory

I have a directory which includes some files and some folders containing other files. I'm trying to remove these files in the main directory without touching the folders or their contents. I'm using ...
-1
votes
2answers
32 views

Prevent a user from deleting the folders and files in his own home

How to prevent a user from deleting the folders and files on his own home directory? In my scenario user can create & modify the folders but user should not delete them. How could we achieve this? ...
2
votes
1answer
29 views

Copy files that partially matches another files in another location

I have a list of jpeg files in a directory like this (below is just a sample, like the structure is the same but this there are many fo0# sub-folders, not only fo01 and fo01, where each of these ...
2
votes
4answers
98 views

Creating directories in a loop and moving files to those directories

Consider a directory with N files. I can list the files alphabetically sorted and store the list by ls > list Then I want to create n sub-directories in same directory, which can be done by ...
2
votes
1answer
29 views

Remove newlines in file names

I have a PHP code that generates the file name on which wget will append its logs. I generated 2000+ files, but the problem is I am having trouble working with them because I had a mistake of putting ...
2
votes
2answers
97 views

Run a command with wildcards in each subdirectory

I use this command to make a montage of all the images in a directory: gmic *jpg -gimp_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0 -o -0000."$(date)".jpg I want to run this ...
1
vote
3answers
45 views

Remove duplicate entries from a CSV file

I've got a [csv] file with duplicate datum reprinted ie the same data printed twice. I've tried using sort's uniq by sort myfile.csv | uniq -u however there is no change in the myfile.csv, also I've ...
0
votes
0answers
31 views

File not read by Java until touched

We had a freak incident on Solaris. Our java program couldn't read a file until we touched the file. It was reading other files just fine, it just seemed to be completely blind to this one particular ...
3
votes
2answers
137 views

Meaning of `cat /dev/null > file`

In a document created by a former coworker there is this command: cat /dev/null > /var/spool/mail/root It says next to it that it will clean out mailbox. Can someone please explain how/why ...
0
votes
2answers
25 views

How to pass arguments to perl when trying to change a line?

I am using the approach suggested in http://askubuntu.com/questions/434051/how-to-replace-a-string-on-the-5th-line-of-multiple-text-files to modify the first line of an archive. Let's suppose the ...
2
votes
2answers
99 views

Script to determine if files are Images

I would like to create a shell script that will check to make sure all files in a directory are image files. We recently had an issue where a hacker was able to generate a file in a directory and ...
3
votes
1answer
72 views

I installed Ubuntu instead of Windows. Where are my files from D drive?

I'm quite new in Linux. I have had a Windows and two drives: C and D. Windows was on C. Then I installed Ubuntu instead of Windows, and I expected my files on D will stay. But I can't find it. As far ...
2
votes
2answers
57 views

File with permissions ---S--l---

Can some one explain what the meaning of these attributes: ---S--l---? When and why need to set this attribute? and for what? $ ls -ltr ---S--l--- 1 root root 0 Mar 10 ...
3
votes
1answer
35 views

Can I limit the size of the linux file cache?

I am running 64-bit Xubuntu 14.04, linux version 3.8.0-25 with 8GB of RAM. I have a script (in MATLAB, for what it's worth) that loads a large number of data files (~23k) one at a time, for a total ...
3
votes
2answers
37 views

Back up and restore file permissions

Is there a way to back up and restore file ownership and permissions (the things that can be changed with chown and chmod)? You can do this in Windows using icacls. What about access control lists?
2
votes
1answer
29 views

Using inotifywait along with vim

I have simple script that monitors file for changes and rsyncs it with remote copy: #!/bin/bash while inotifywait -e close_write somefile do rsync somefile user@host.domain:./somefile done It ...
1
vote
1answer
30 views

How do I synchronize 2 xml files?

I have 2 xml files named 1k.xml and 1n.xml. The file 1k.xml contains some additional elements and data which are not there in 1n.xml. I want to copy whatever is absent in 1n.xml to it, so that both ...
2
votes
0answers
33 views

Higher-level wrapper for entr or inotifywait

I'm looking for a way to rerun a specific command as soon as any of the files in a subdirectory (perhaps minus selected excludes) changes. Use case I'm working on a project that is self-contained in ...