Logical entities that contain data in a filesystem. Use this tag if your question: is about programs that create files (e.g. gzip, tar, zip); deals with characteristics of files (permissions, size, path/location); or is about management of files (renaming, listing, moving, removing). For operating ...

learn more… | top users | synonyms (1)

4
votes
3answers
5k views

Identify and assign most recent file to shell variable

I have a directory of .jpg files that continuously grows. I want to copy the most recent one elsewhere. This is what I currently have and it works, just curious if there's a better way to identify the ...
4
votes
1answer
1k views

How many files can be saved in one directory on Linux? [duplicate]

Possible Duplicate: Number of files per directory I need to save 1 million static html files in one directory as there is not possible to group the files into the directories (all files must ...
3
votes
2answers
125 views

Test for a particular file format

This is a followup to Normal looking text file, detected by file as ASCII Pascal program text It seems file can't be trusted all the time. It seems possible that a particular file may be detected ...
7
votes
1answer
494 views

Delete files older than 500 days

I have directory with files from 2010 year.. I want to delete all files older than 500 days and I tried this: find /var/log/arc/* -type f -mtime +500 -delete {}\; But I get this: -bash: /usr/...
3
votes
1answer
362 views

How does the Linux file structure work?

I see the different folders bin, dev, mnt, proc, srv, sys, etc. What are the properties of all these different folders? What are their purposes? Are there files in some of them that I should not ...
3
votes
1answer
209 views

Process exceeding max open files limit

I am counting current open files by a process pid by :- cmd1:- ls /proc/$pid/fd/* | wc -l and then I am calculating percentage by fetching Max open Files limits. cmd2:- $ cat /proc/$pid/limits ...
1
vote
1answer
30 views

Is there any way I can track down what is removing the executable flag from a file?

I have a set of git hooks that constantly have their executable flag removed. I'm utterly at a loss for what might be doing it, but so far the only thing I've found that can even mitigate the problem ...
-2
votes
2answers
41 views

has a file changed of value [on hold]

im trying to use pyinotify to detect if a file has changed. managed to do it this way def status(argument): global email_alarm_status global new_email_alarm if not email_alarm_status: ...
2
votes
2answers
38 views

How do I find files with multiple empty lines?

For replacing multiple empty lines with just one I need to find which files to apply this in the first place, in a big repository. How do I do that?
2
votes
1answer
160 views

Unable to run chmod, chown, and even ls on a folder

I searched the net and tried to apply answers to similar problems but none worked so far. There is a folder named ocrpaylasim under /home/bnet path. This file belonged to bnet user before and was ...
3
votes
1answer
121 views

How do I recursively set the date created attribute to the date modified attribute on NTFS-3G?

In my first question, I asked how to get the "Date created" field in NTFS-3G. Now, that I know I can get the "Date created", I have started adding files onto my NTFS-3G partition and would like to set ...
4
votes
1answer
124 views

Get consistent encoding for all files in directory

I have a directory containing lots of csv files from various vendors with two different encodings: ASCII Text / UTF-8 UCS2 / UTF-16 little endian I'd like to use grep, awk, sed and other utilities ...
1
vote
1answer
22 views

perl + uniq characters before variable

Please advise What is the meaning of the characters "%%" before the variable EOF ? $LINE =`tail -1 $FILE `; chomp($LINE); if ($LINE eq "%%EOF") { . . .
0
votes
1answer
42 views

Delete files older than X days - mtime, ctime and atime doesn't work

I'm running a script on synology (NAS) that is deleting files older than x days on certain folders. The problem is that I want these files to be deleted after X days of being uploaded on the folder. ...
3
votes
2answers
78 views

How to Run a command on all subfolders

If you have a series of sub folders (like from a to z) and want to run a command on each one of them (like dsmmigrate * & ) how do you do that? The manual approach would be, cd a dsmmigrate * &...
1
vote
2answers
39 views

How to split a 6 or 7 GB file into several sub-2 GB files without splitting entry?

My level has 6 to 10 GB sized files as input. These files contain several lines of data. The next level's max input capacity is 2GB. So I have to split these 6-10 GB files into several sub-2 GB files ...
12
votes
2answers
488 views

How to set file permissions with touch command

It seems that whenever I create file with touch the permissions are set to: -rw-r--r--. Is there some way that I can configure the permissions differently with touch or does this have to be done after ...
0
votes
2answers
63 views

Reading a file incrementally

I have requirement where I need to read part of the file which was updated from the last read. I mean if I read the file last time at 2016-07-26T01:30 and after I want to run again at 2016-07-26T02:...
1
vote
1answer
19 views

Find capacity details and oldest file in Busybox format

I am using Mobax and it has Busybox installed in it. I can successfully get the capacity, available, used and used percentage of the directory and its sub-directories in Linux by typing: clear &&...
10
votes
2answers
508 views

How do I grant different permissions for each user?

So, I've been using Linux for a few years now, and I really should know this answer, but I'm having trouble finding it. Specifically I've been using Debian based distro's....mostly Ubuntu. If I have ...
0
votes
0answers
42 views

What may go wrong while copying file? [on hold]

I am writing a library as part of learning a new language which copies a file. The task is to copy the file content as using the nodejs Stream API. I am interested in knowing what can happen wrong ...
34
votes
4answers
12k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
0
votes
1answer
35 views

Restore system file permissions

While I was setting up an Ubuntu server (EC2), I accidentally run the following: sudo chown -R www-data.www-data /* very dumb and noob move on my end. Anyway, is there an easy way to restore all ...
56
votes
10answers
134k views

How to list all files ordered by size

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
7
votes
5answers
7k views

Delete spaces, hyphens, and underscores in filenames?

What is a good command to delete spaces, hyphens, and underscores from all files in a directory, or selected files? I use the following command with Thunar Custom Actions to slugify filenames: for ...
4
votes
4answers
2k views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
2
votes
3answers
37 views

Is it “broken” to replace an existing file without fsync()?

In Linux's mount(2) man page, I noticed the following excerpt: Many broken applications don't use fsync() when replacing existing files via patterns such as fd = open("foo.new")/write(fd,...)/...
7
votes
1answer
159 views

Why does OS X `install` errors on redirected input when the same version of `install` on linux works fine?

I would like to use install command in order to create a new executable file with pre-populated content (e.g. with single pwd command in it). So I've extended this example which creates a new empty ...
20
votes
1answer
3k views

gvim -p limit of opened tabs?

When I run : gvim -p *.xyz I find that not all files are opened in tabs. It feels, like a kind of tab limit? But ! When I try to open unopened with : :tabnew it is opened next to previous ...
2
votes
1answer
25 views

Does linux tar block write access to files

I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer. I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, ...
3
votes
6answers
159 views

How one can re-read image with dd so it will match one you just wrote?

I have a ~1GB image that I'm writing to a 8GB SD card via the dd tool. I'd like to verify that it was written without corruption by reading it back and comparing its hash with original one. Obviously,...
7
votes
3answers
671 views

How can I safely ensure a variable contains only a valid filename?

Given the script below, how can I ensure that the argument only contains a valid filename within /home/charlesingalls/ and not a path (../home/carolineingalls/) or wildcard, etc? I only want the ...
0
votes
0answers
31 views

No such file or directory: But file exists [closed]

I am stuck in a very weird problem. I have a Bash script in a server A which is called from server B using another script. The script from server B returns "No such file or directory". The file is ...
0
votes
1answer
26 views

How can I retrieve the permissions of a file in a certain format? [duplicate]

I can change the permissions of a file by: chmod 600 ~/.ssh/authorized_keys How can I retrieve the permissions of a file in the same format which is 600?
2
votes
4answers
66 views

Extract the directory path containing the file with matching string

I have multiple subdirectories at multiple levels containing a file results.out ./dir1/results.out ./dir2/dir21/results.out ./dir3/dir31/dir311/results.out Now i need to search for string1 in ...
0
votes
1answer
17 views

How to write and handle custom log file properly?

I had a task that I have to write up a simple bash script which in turn executes admin command from Websphere Application Server (WAS). I put it into /etc/cron.daily folder hoping it would be executed ...
11
votes
3answers
7k views

find with -execdir

When I run find with -execdir I don't get the results I was expecting. For example: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
-3
votes
2answers
171 views

Find the number of files with sizes

Find the number of files with sizes > 100KB in /, /bin, /usr, /usr/bin and /usr/sbin directories and output them in a two column format with the name of the directory and the number of files.
0
votes
3answers
1k views

Creating a character device file

How to create the character device files? I have tried cat > xxx^c But I can't create a character device file
-1
votes
4answers
42 views

Extract files from a directory and save the files' names and sizes in KB in a CSV file

I want to retrieve all the .log files from the directory /var/log, store the results in a csv file along with each log file's respective file size in kB. I started by getting the files using find: ...
1
vote
1answer
33 views

Clearing folders except specific type of files

I have tree of folders as follow: parent folder ....folder A ....folder B ....folder 1 ....folder 2 ....folder C ....folder 1 ....folder 2 ....folder D ....folder 1 ....folder ...
1
vote
2answers
50 views

Unable to delete files through Terminal

More recently, I have been using rm -r /path/to/file to delete files, but when deleting from certain locations, I get the error: override rw-r--r-- root/admin for filename? I have tried entering y, ...
3
votes
2answers
44 views

Protect session log from being written again by anyone

We have implemented a workaround to save command history in a new file for each user session for audit purpose. So each session file is identified by the start time and the username. The problem: The ...
1
vote
2answers
37 views

list files with similar names sorted by similarity [closed]

Is it possible to search files and list them descending by similarity ? e.g.: Following files are in /: heo HELLO helo hello When I search for 'hello' I would like to have a List like: ...
4
votes
3answers
189 views

Shell script: “if file is not being used” condition

I'm trying to compress a virtual machine image file through a script, but I want to be sure the file isn't being accessed. I could check if virt-manager is running, since it should be the only program ...
4
votes
2answers
1k views

Why does touch create new files?

I am aware that the touch command is used to update the date of last modification on a file. It is also used to create a new file if requested file does not exist on file system. Since touch (as it's ...
71
votes
6answers
62k views

What is a Superblock, Inode, Dentry and a File?

From the article Anatomy of the Linux file system by M. Tim Jones, I read that Linux views all the file systems from the perspective of a common set of objects and these objects are superblock, inode, ...
4
votes
1answer
67 views

accessing path from outside the root with symlink

I need to add an outside path to my apache configuration. (httpd) so, I made a symlink to this path in my httpd root folder, the path is: /var/log/httpd/ (I want to display logs directly in my ...
1
vote
2answers
1k views

How to give sftp access to sub-directory only not to parent

I want to give SFTP access to user tom for directory /var/www/html/my_project/. while I don't want to give any SFTP access to directory /var/www/html/. currently /var/www/html/my_project/ and /var/...
2
votes
2answers
345 views

How to remove a file that can be seen but no program can seem to touch?

I'm trying to remove some obsolete backups, and deep inside one I've found a file 'cifs3bee' that I can find no way of removing. (And since I can't remove it, it's preventing the removal of the entire ...