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

learn more… | top users | synonyms (1)

1
vote
3answers
65 views

How to scp all files of a certain owner?

I want to scp all files of certain owners. For example, if this is my ls -la output: -rw-rw-r-- 1 owner1 ad 704 Jun 1 18:16 file1 -rw-rw-r-- 1 owner2 ad 798 May 29 11:15 file2 -rw-rw-r-- 1 ...
3
votes
2answers
171 views

change file size format when using stat

The formatting character %s makes stat print the filesize in bytes # stat -c'%A %h %U %G %s %n' /bin/foo -rw-r--r-- 1 root root 45112 /bin/foo ls can be configured to print the byte size number ...
5
votes
6answers
118 views

How to find out whether two directories point to the same location

Do the following paths point to the same disk location? /home/username /app/home/username
4
votes
4answers
395 views

How can I get the size of stdin?

I'm about to compress a large directory and I want to know how large, exactly, the resulting file will be. I've tried using du: $ tar -cv dir | du -h - du: cannot access '-': No such file or ...
2
votes
2answers
47 views

Selecting a random sample from a directory tree

I've got a directory that contains directories that contain directories that contain files. I'd like to select two files at random from each leaf directory. I found this question about selecting ...
2
votes
1answer
71 views

Batch Extract & Repack .RAR Files

I'm dealing with a large amount of password protected .rar files which need to be repacked to remove the password. (The password is known.) I was wondering if there was a script to batch/recursively ...
3
votes
2answers
244 views

Why can't I delete this file as root?

I have directory exam with 2 files in it. I need to delete files but permission is denied. Even ![rm -rf][1] command can't delete these files. I logged in as a root user.
1
vote
3answers
99 views

Script to move one filetype and create a subfolder, if it exists?

I'm trying to find a script that would basically look recusively at a directory, and if the script finds file that are .flac files, it will create a subfolder called FLAC in that same folder, and move ...
3
votes
2answers
56 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 ...
1
vote
0answers
27 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
2answers
101 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
1answer
80 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
72 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 ...
0
votes
1answer
25 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 ...
3
votes
3answers
77 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 ...
3
votes
3answers
44 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 ...
1
vote
2answers
90 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 ...
3
votes
3answers
85 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 ...
4
votes
4answers
439 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 ...
4
votes
4answers
286 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
vote
1answer
73 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 ...
0
votes
1answer
24 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 ...
2
votes
2answers
71 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
2answers
60 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 ...
1
vote
1answer
36 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 ...
4
votes
4answers
122 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 ...
0
votes
2answers
50 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. ...
0
votes
2answers
65 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 ...
1
vote
1answer
78 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 ...
1
vote
2answers
66 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, ...
0
votes
1answer
47 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.
2
votes
1answer
51 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 ...
6
votes
5answers
436 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 ...
7
votes
2answers
255 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 ...
1
vote
1answer
49 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 ...
2
votes
2answers
70 views

How can I start a file-processing daemon? [closed]

How can I run a script-based tool which will process files continuously downloaded to given directory as they arrive? I'd like to minimize delay (~1 second is OK), script can have own infinite loop. ...
18
votes
5answers
668 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?
0
votes
1answer
27 views

UMASK not having effect on some file creations

I have umask set to 002 in my Linux server and its working fine while I create file using touch. But I still have some files that are created with permission contrary to umask. These problematic files ...
3
votes
2answers
48 views

Is it possible to have a lag between scp and checking for new file

Got a cronjob that downloads things regularly: if ! su scpuser -c "scp ..." > /dev/null 2>&1 || ! [ -f $scptarget ]; then; error "did not download stuff" $scptarget is where the thing ...
2
votes
2answers
422 views

Why does touch create new files?

I understand that this might be a very strange question to ask, but I couldn't help my curiosity, and I couldn't find this anywhere on the net (And I'm too lazy/incompetent to look up the source ...
4
votes
1answer
127 views

Unexplained files found in home folder

For background information, I'm running openSUSE 13.2 and KDE 5. Today I found a number of unexplained files and folders in my home folder which state they've been edited 3 days ago. I do not ...
0
votes
2answers
112 views

Files greater than 1 GB and older than 6 months

I want to find files which are greater than 1 GB and older than 6 months in entire server. How to write a command for this?
2
votes
1answer
24 views

Seeing all regex matches in a file in Bash

I'm in bash and I have a file, I want to find all matches of a regex in it and have them printed. How do I do that? Followup: Assume I want to print only unique matches, i.e. if a match appears ...
33
votes
4answers
1k views

Does bash open files in O_APPEND when using “>>” on linux?

If we use echo 1234 >> some-file then Documentation says that the output is appended. My guess is that, if some-file does not exist, then O_CREAT will make a new file. If > was used, then ...
6
votes
3answers
247 views

How to copy a directory recursively using hardlinks for each file

I want to create a "copy" of a directory tree where each file is a hardlink to the original file Example: I have a directory structure: dirA/ dirA/file1 dirA/x/ dirA/x/file2 dirA/y/ dirA/y/file3 ...
2
votes
3answers
92 views

Is it possible to create dynamic content on file read operation?

Is it possible to generate file content based on file name? I need a lot of similar .conf files with content depending on file name only. Can I create some "dynamic" file and generate a bunch of ...
4
votes
3answers
131 views

Why can't I read /dev/stdout with a text editor?

I just started learning how Everything Is A FileTM on Linux, which made me wonder what would happen if I literally read from /dev/stdout: $ cat /dev/stdout ^C $ tail /dev/stdout ^C (The ^C is me ...
1
vote
3answers
73 views

How to change the permission and group-owner of a file at the same time

For changing file permission, I know I could use chmod. For changing group-owner, I could use chgrp. However, if I want to change both permission and owner at the same time, any command I could use on ...
8
votes
2answers
430 views

Create a gzip file of a predetermined size

I want to test an upload of files of content type application/x-gzip of various sizes ranging from 100 MB to 999 MB. How can go I about creating .gz files of these predetermined sizes? If I do dd ...
4
votes
2answers
98 views

Are files defined by their content blocks, inodes, both, or filenames?

Are files defined by their content blocks, inodes, both, or filenames, or something else? Fundamentially, what is the definition of a file? E.g. two hard links can share the same inode and thus ...