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

learn more… | top users | synonyms (1)

3
votes
2answers
43 views

Use USB to synchronize large directory between two disconnected servers

I'd like to synchronize a large directory between two disconnected servers with a USB device that's too small to hold the entire directory. Each server has a majority of the data and the changed files ...
0
votes
0answers
18 views

Why does a file marked deleted persist even after OS reboot and how does one remove it?

RHEL 5.10 (kernel 2.6.18-371.6.1.el5); file system is ext3. This "machine" is a VM on VMware 5.5 FWIW. I see the same file marked as deleted through lsof and /proc//fd after the application restarts ...
3
votes
3answers
46 views

Copying a Parent Directory into a Subdirectory Without an Infinite Loop

For application specific reasons, I need to copy an entire parent directory into a subdirectory. E.g., cp -r ../ tmp/ The problem with this is that it gets stuck in an infinite loop, recursively ...
27
votes
4answers
12k views

Clone ownership and permissions from another file?

Is there a command or flag to clone the user/group ownership and permissions on a file from another file? To make the perms and ownership exactly "like" that of another file?
1
vote
0answers
22 views

Is there any considerations I should take when running untrusted apps as non-root user?

I have to use an application I don't trust (unstable) and I will run it as a non-privileged user so if something bad happens the damage would be limited to the home folder of that user. I removed ...
2
votes
1answer
19 views

NFS permission problem with secondary groups

I have a server running Debian 7 that exports an NFSv3 share, and a client running Centos 5 that accesses it. This works fine, except for one issue with permissions based on non-primary groups. When ...
2
votes
1answer
41 views

Get all filenames in a directory created before input date

I have a directory containing lots of files. The output of ls command is -rw-r--r-- 1 nobody nogroup 427494 May 26 13:59 14_20150526065238928590_102.txt -rw-r--r-- 1 nobody nogroup 2113592 May ...
2
votes
2answers
33 views

Copying latest file from remote server

There is a collection of .doc files, in addition to other types of files, on a remote server (which supports SCP). I am trying to write a script to retrieve the latest (most recently modified) .doc ...
2
votes
4answers
3k views

move file by list in file

I have a file that contains file names. For example: /tmp/list.txt (it is with the spaces at the start of each line): /tmp/file.log /app/nir/home.txt /etc/config.cust I want, using one ...
5
votes
2answers
590 views

How to delete a directory automatically when an executable is killed

Quite often, we run an executable that needs to write / read some temporary files. We usually create a temporary directory, run the executable there, and delete the directory when the script is done. ...
3
votes
3answers
36 views

Is there a way of listing all the instances when a particular file was modified/edited?

I currently have a file abc.txt. I am curious to know if it is possible to see all the instances when this file was edited, from the date it was created? Q: How can I make it possible [if I would ...
0
votes
1answer
18 views

Execution bit not being set [duplicate]

I have just set up an EC2 instance to play around with and am testing file permissions; however, I notice that the execution bit is not being passed down to the lower level (read and write are, just ...
4
votes
4answers
16k views

Linux file access monitoring

Is there any way in unix to find out who accessed certain file in last 1 week? It may be user or some script ftp it to some other place. Can I get a list of user name who accessed certain file? How ...
0
votes
2answers
81 views

Execute scripts without decrypting them

I have a set of scripts (bash, ruby, python) and want to put everything into a container like file so I can deploy this container on a lot of servers. This scripts need to protect from accessing other ...
20
votes
2answers
27k views

Empty the contents of a file

I am aware of three methods to delete all entries from a file. They are >filename touch filename filename < /dev/null Of these three I abuse >filename the most as that requires the ...
1
vote
2answers
71 views

Find largest files of a particular owner

I accidentally chown'd my entire file system to a particular user, after correcting the issue I've found disk space still being consumed by that particular user's files even though their account ...
27
votes
4answers
15k views

Reading lines from a file with bash: for vs. while

I'm trying to read a text file and do something with each line, using a bash script. So, I have a list that looks like this: server1 server2 server3 server4 I thought I could loop over this using ...
4
votes
4answers
248 views

grep command not working in conditional statement

I've a bash script that's supposed to go over all the filenames and print them only those that contain a certain letter (let's say it's 'o'). What I've done: command=`ls -l` for file in $command do ...
3
votes
3answers
60 views

How to change suffix of the files

In a directory structure which has multiple subfolders and files in it. Some of the file names have the suffix _create (e.g. java1_create) and some of them with _bak (java2_bak). I need to rename ...
1
vote
2answers
143 views

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
-11
votes
0answers
45 views

unix standard file streams [duplicate]

Each Unix process has three standard file streams associated with it. Give two of these streams and give a command line example of each being re-directed
2
votes
1answer
11k views

How to add 'open folder as root' in Elementary OS file manager context menu?

Here it is the solution in order to add the 'open terminal here' into the context menu of Elementary OS' file manager (generically called 'Files' - the executable is pantheon-files). For that ...
22
votes
2answers
30k views

How can I increase the number of inodes in an ext4 filesystem?

I had a problem (new to me) last week. I have a ext4 (Fedora 15) filesystem. The application that runs on the server suddenly stopped. I couldn't find the problem at first look. df showed 50% ...
4
votes
4answers
142 views

Move files by date into different directory using CLI

I have a large number of pictures from an old hard drive that I'm trying to organize. If I run ls -l, I notice all of these files have a creation date of 2012 or before. Ideally, I'd like to move ...
-1
votes
2answers
48 views

Error in file comparison - awk [duplicate]

I have two files file1.txt, file2.txt. I want to select records which are common to both file1.txt and file2.txtbased on column 2 and column 3 and copy them to out.txt with additional column(column 4 ...
2
votes
2answers
63 views

How do I check which files are written by an application?

On my system, sar reports an average write to disk about 5MB/s. Using dstat I found that it's not so permanently, but there are peaks to 30-50MB/s, and then are sleeps. Using iotop i found that most ...
0
votes
1answer
20 views

Returning last-written file, containing particular sub-string in file name?

Whilst monitoring logging I have to go to my log files, order by written date, so I can then see the name of the log file for the most-recent execution of my application. Is there any way, given a ...
1
vote
1answer
48 views

Comparing a bunch of files on different folders

I have two folders with 200 txt files each, all files named like file1.txt, file2.txt, file3.txt, etc., on both folders. Is there a way to use one command to compare file1 in both folders, file2 in ...
4
votes
4answers
105 views

Stable sort a file by presence of ordered substrings on each line

I have a list of sound sources that I'm processing with a script. An example would be: alsa_input.usb-AVEO_Technology_Corp._USB2.0_Camera-02-Camera.analog-mono ...
1
vote
1answer
19 views

Generating a long sound file with SOX without actually playing the tone

I know how to play a tone for a specific amount of time using SOX. play -n synth 5 sin 347 I know how to save a tone using SOX. sox -n note.mp3 synth 5 sin 347 Question is : How can I save a ...
57
votes
3answers
49k views

How to tell gzip to keep original file?

I would like to compress a text file using gzip command line tool while keeping the original file. By default running the following command gzip file.txt results in modifying this file and renaming ...
2
votes
3answers
93 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 ...
7
votes
5answers
673 views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to another file, without sed and awk? For example: $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
0
votes
2answers
42 views

Change the owner of a file I can write to

I have a folder called fruit with permission 777 and its owner is fruit. I want to create a folder named apple under the fruit folder. But I want to set this folder's owner as apple, not fruit. ...
1
vote
0answers
30 views

Why use mmap over fread? [migrated]

Why use mmap as opposed to reading from a filestream in chunks into a byte array? I guess I just never thought about using mmap before. mmap(2) fread(3) // Open the file // Read from the file ...
2
votes
1answer
112 views

How can I check if rsync made any changes in bash?

I have a script which uses rsync to sync data in a remote -> local scenario. Immediately after the rsync command is run, a check to see if the error code equals zero or not. If its zero, further ...
0
votes
2answers
34 views

Generate a list of installed PHP extensions

My goal is to write an as simple as possible (but not more simple) that generates a list of currently installed PHP extensions (*.so files) that the user can simply copy/paste into their php.ini. It ...
0
votes
1answer
29 views

Delete excel files which are older then 1 month

I need to delete excel files which are older then 1 month. need to set cronjob. any suggestion for this? which script can be used to search excel files from particular directory and delete them.
10
votes
4answers
3k views

Can I make `cut` change a file in place?

The man page doesn't give me much hope, but I'm hoping it's an undocumented (and/or GNU-specific) feature.
1
vote
2answers
51 views

Compare three files: lines present in one, but not in the other using column comparison

I have three files file1.txt, file2.txt, file3.txt and they are of same format(same number of columns with same data type). I want to select records from file1.txt which are not present in file2.txt, ...
1
vote
1answer
45 views

sort file based one colum and group by another column

I have a file of three columns: 1 A 0.5 2 B 0.7 3 A 10 4 C 4 5 B 4 I want to sort the file by increasing order of column 3 and group by column 2 1 A 0.5 3 A 10 ...
0
votes
2answers
114 views

Expect Scripts - Reading from Files and Accepting User Input

How can I write an "Expect" script to: iterate over a list of IP addresses and log in to each to perform commands (like in a BASH for loop). Right now I just copy/pasted the few lines that are my ...
7
votes
1answer
6k views

How to change the default program for a specific file extension system-wise in kde or xfce?

I'd like to have certain file extensions to be opened with some specific programs. What are the files the edit ? I have found in /usr/share/appplications/default.list but it doesn't work.
2
votes
1answer
38 views

How to compare two directories thoroughly without git?

Here thoroughly means “list all differ files, find those files with same name and different content, list the difference of content”. Before I got a lazy solution, git init one directory and copy ...
-1
votes
0answers
11 views

Where to find rescan-scsi-bus.sh in linux os

I can't find the rescan-scsi-bus.sh. I installed yum install sg3_utils. Where to find this file? I checked in /usr/bin/rescan-scsi-bus.sh but i didn't found it.
18
votes
5answers
543 views

Find files that a user can write, efficiently with minimal process creation

I am root. I would like to know whether a non-root user has write access to some files - thousands of them. How to do it efficiently while avoiding process creation?
6
votes
5answers
202 views

How to execute a bash command in all possible subdirectories?

Let's say my main directory is /home/test Under it i have lots of subdirectories and under subdirectories still a lots of them and so on. Example: /home/test /home/test/subdir1 ...
1
vote
1answer
29 views

Assigning ls output to a variable gives unexpected behavior

I was writing a script to clean a text file from a directory (I know,it's a bad idea but I really need it) and I wrote this: #!/bin/bash var=$(ls -p /direcotry/to/file | grep -v /) truncate -s 0 $var ...
9
votes
3answers
2k views

find with -execdir

I run a find with -execdir both I don't get the results I was expecting. SSCCE below: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
5
votes
2answers
148 views

How to sync two folders with command line tools?

Having migrated to Linux from Windows, I would like to find an alternative software to Winmerge or rather learn command line tools to compare and sync two folders on Linux. I would be grateful if you ...