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

learn more… | top users | synonyms (1)

2
votes
5answers
128 views

Finding new lines in one file compared with another

I need to compare two txt files. Every line of both txt files contain entries. One entry per line. The new file contains entries the old one lacks. I have tried to use diff and vimdiff but these don't ...
2
votes
1answer
45 views

Maximum time a file descriptor can be held

I am writing a long-running program in the Linux environment that will be calculating entries in a large table. Every time it comes to the end of the row, it outputs the calculated values into a ...
1
vote
2answers
125 views

Change file ownership, based on previous owner

I am a moderately new linux user. I changed my PC, and started using CentOS 7 from CentOS 6. So I attached my previous hard disk to my new pc to take backup of my files. Now, copying the files (and ...
1
vote
3answers
34 views

Why does Debian prefer a temp file replacing the original over modifying bytes in original file?

In the mp3gain manpages, you can read the following: -t mp3gain writes modified mp3 to temp file, then deletes original instead of modifying bytes in original file (This ...
5
votes
3answers
225 views

Bash: Zipping/grouping files by common substring

I have about 100 files. They are named like this. 3000_ABCD_XXXXXXX.csv 3000_ABCD_YYYYYYY.csv 3000_ABCD_XYXYZYZ.csv 3000_EFGH_XXXXXXX.csv 3000_EFGH_YYYYYYY.csv 3000_EFGH_XYXYZYZ.csv ...
2
votes
1answer
59 views

Add content one file to another

FILE1=$1 FILE2=$2 if [ ! -e "$FILE2" ] then touch $FILE2 fi while read line; do if grep -q "$line" $FILE2 then echo else echo $line >> $FILE2 fi done < $FILE1 I want ...
4
votes
1answer
680 views

Automatically detect when a file has reached a size limit

I would like to send an email when a file reach a certain size limit. The only way I thought of doing this is by doing a cronjob which will check the file size and send the email if the file is ...
6
votes
1answer
672 views

How are extended attributes stored and preserved?

I have a small question about extended file attributes. Assume I label my files with metadata in extended attributes (e.g. to account for the integrity - but this does not matter for my question). The ...
1
vote
1answer
45 views

Postfix no longer logs to /var/log/mail after it has been deleted and re-created?

I accidentally deleted the /var/log/mail file. Until that point I was able to monitor it using postfix stuff. Now, it seems that Postfix doesn't send its logs to /var/log/mail, since the file is not ...
4
votes
3answers
208 views

Add text with echo but start with new line if file not empty

I'm trying to create next script echo "#!/bin/sh" >/script echo "del x.txt" >>/script witch is ok if /script file is empty, if not - will append first line to last text #!/bin/sh del ...
3
votes
3answers
92 views

How to use all the inodes

Without creating a file can I use any inode which is free? I want to write a script that will use all free inodes in the system. is it possible?
0
votes
0answers
22 views

Change encoding of a text file in-place: iconv alternative? [duplicate]

Apparently, iconv is unable to use the same file as input and output file. Other tools, e.g. sed, have an -i switch that allows "updating" a file in-place. (Under the hood, temporary files are ...
1
vote
3answers
389 views

In a Bash if condition, how to check whether any files matching a simple wildcard expression exist?

Stupidly, I had been using a condition like this as part of a script: if [ $(ls FOO* 2> /dev/null) ] # if files named "FOO*" were downloaded then echo "Files found" # ... process and ...
0
votes
1answer
91 views

Why the size of an empty directory in Linux is 4KB? [duplicate]

I'm using Ubuntu 14.04 and I made an empty directory on /tmp with the mkdir command: cd /tmp mkdir foo and then I checked it's size using ls: ls -ldh foo and the result shows that the size of ...
1
vote
0answers
33 views

open() sys call [closed]

Process A wants to open a file fd1 = open("/var/file1", O_RDONLY); In the process of opening file1 which table is referred first system wide file table or file descriptor table or in-core inode ...
3
votes
4answers
142 views

Convenient way to name files in Linux

I'm a beginner in Linux and want to learn to do things properly in this environment. Since the beginning I've noticed that a lot of people involved in Linux (like tutorials and guides) tend to name ...
1
vote
3answers
88 views

Find and delete duplicate txt files

I have a folder with around 300 text files, is there any command that reads every every file indivdually and deletes the duplicate files? I mean the content and not the file names.
4
votes
1answer
189 views

Why doesn't inotifywatch detect changes on added files?

I'm trying to monitor my /tmp folder for changes using inotifywatch: sudo inotifywatch -v -r /tmp After creating couple of files (touch /tmp/test-1 /tmp/test-2), I'm terminating inotifywatch (by ...
2
votes
1answer
71 views

How do I choose a file names with consecutive numeric suffixes?

I like to preserve things, so I want to preserve .bash_history. I would like to copy it into a directory using a script. Like here #!/bin/bash #Something here? number=~/Desktop/Coding/Bash\ ...
1
vote
3answers
51 views

How to access temporary file straight after creation?

I've script which is connecting to remote host via SSH, creates temporary file and executing the following command: Calling system(mysql --database=information_schema --host=localhost < ...
26
votes
5answers
16k views

How to determine which process is creating a file?

Given file path, how can I determine which process creates it (and/or reads/writes to it)?
2
votes
1answer
34 views

Which types of files can have a shared library dependency?

I'm trying to find a way to let the find command only find files, that could possibly have a shared library dependency (meaning they produce output when called with ldd). To find all dependencies of ...
1
vote
4answers
45 views

How to do grep even if the file is not present?

I am doing something like this in my code file_nm=`ls -latr *abc*` if [ `grep "search_txt" "$file_nm" | wc -l` -gt 0 ] then echo "string found" else echo "string not found" fi If the file_nm is ...
2
votes
1answer
69 views

In a Virtualbox VM how do I set the filesystem permissions?

I have a virtualbox VM with arch Linux running on my windows PC (which I unfortunately have to use for work). I use this to work on my windows PC with a Linux environment as an alternative to Cygwin. ...
24
votes
2answers
1k views

Is it safe to move a file that's being appended to?

I have a node.js process that uses fs.appendFile to add lines to file.log. Only complete lines of about 40 chars per lines are appended, e.g. calls are like fs.appendFile("start-end"), not 2 calls ...
1
vote
1answer
17 views

What files does affect apt-get purge¿?

I want to know before doing apt-get purge <packet> what files thats gonna have effect on. The reverse thing would be, what packet do I have to do purge if I want to remove that file (apt-file ...
1
vote
1answer
57 views

Create a file that's really a network port

I have a program running on a cluster, and the output of the program is written to a log file which I specify. However, instead of writing it to a file, I want to write it to a network port, so that ...
1
vote
1answer
137 views

How to output the directory structure to Json format [duplicate]

I have been using 'find' to output the directory structure from the root down and I don’t mind that it takes a while. My problem is that I want to cut down on the redundant info of repeating every ...
4
votes
1answer
74 views

How to make sure only one instance accessing the file at a time in a folder?

I have a shell script which will be executed by multiple instances and if an instance accessing a file and doing some operation how can I make sure other instances are not accessing the same file and ...
51
votes
15answers
15k views

Is there an easy way to replace duplicate files with hardlinks?

I'm looking for an easy way (a command or series of commands, probably involving find) to find duplicate files in two directories, and replace the files in one directory with hardlinks of the files in ...
2
votes
3answers
117 views

print the /etc/shadow file in the console

How do I change the permissions of an executable file to access the /etc/shadow file? So far I have the following bash script: #!/bin/bash gcc print.c -o print chmod +s print ./print exit 0 and ...
6
votes
3answers
276 views

Is it possible to create an edited copy of a file without using up extra disk space?

If I have a large file, I can use ln to make make "copies" of it that don't use up extra disk space. But what if I don't want an exact copy of the file? Is there a way to create a new version of a ...
12
votes
4answers
811 views

Drop a specific file from the Linux filesystem cache?

I know I can drop everything from the Linux filesystem cache, but is there a way to drop just one specific file? Or prevent a file from being cached? Or tell a process not to cache any files it ...
2
votes
3answers
124 views

How to remove file with mv command?

I started to study Solaris in my university. Teacher told me to remove a file with mv command. I tried to move a file to /dev/null. But that did not work. How can I remove file with mv command?
0
votes
1answer
32 views

Is it possible to access these directories?

I'm trying to recover data from my Ready NasDuo which is Spark based with a 16kb block size. I've followed another post and successfully mounted the drive using a command like sudo fuseext2 -o ...
3
votes
3answers
114 views

Sorting directories by last modified date/time of the same-named contained file

Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example: domain1/file.php (last modified 20-Jan-2014 ...
1
vote
0answers
27 views

Command that can find files that are not referenced by other files and then delete them

I was wondering if anyone knew how I could go about writing a grep command that recursively finds files that are not being referenced/used in a specific file and/or a directory of files, and then ...
1
vote
1answer
28 views

Hexdump binary file while honoring separators

I have a binary file where records are separated by newlines. hexdump just dumps everything with a fixed column width. Is there a tool to hexdump this file, while honoring the newline separator? (Any ...
0
votes
1answer
52 views

How to move a file to another directory, as soon as it is created, in linux? [duplicate]

I want to move all the *.xxx file created in a directory to another directory. But, I want that as soon as the files are created, they should move to another directory. Please Help. Thanks in advance. ...
3
votes
1answer
39 views

How to find the file corresponding to a pipe opened by a process? [duplicate]

I created this script, which listens for characters received on a hardcoded pipe, and tries to eval those characters. I call my script loop_executor.sh This is all it contains: !/bin/bash while : do ...
0
votes
1answer
43 views

File tranfer from the server

I want move (not copy with scp) my file from the server to the local repository and finally delete it on the server after transfer. I use next command from the repository, where I want have the file: ...
2
votes
1answer
49 views

How can I encrypt a file?

I would like to download some files from my server into my laptop, and the thing is that I want this communication to be as stealth and secure as it can be. So, far I came up using VPN, in that way I ...
6
votes
2answers
1k views

What is the result of running `chmod 7` on a file?

I know chmod 777 allows read, write, and execute for user, group, and others but what if I just do chmod 7? Is that only rwx for the user?
1
vote
1answer
78 views

Noip “Can't locate configuration file”, but the file is there

I installed Noip and ran the command which created the config file /usr/local/bin/noip2 -C and then I ran the run command /usr/local/bin/noip2 and it returned Can't locate configuration file ...
1
vote
3answers
561 views

Script to count files matching a pattern in subdirectories

I wrote the following script for finding the number of pdf and tex files from the current directory, including the subdirectories and hidden files. The following code is able to find the number of pdf ...
0
votes
1answer
59 views

What has priority - owner/user vs group permission? [duplicate]

I have just run into the case in which the owner-group of a file has more permissions than the owner-user of a file. user1@pc:/tmp$ ls testfile -l ----rw---- 1 user1 user1 9 Okt 16 13:16 testfile ...
4
votes
2answers
167 views

Precedence of user and group owner in file permissions

I just ran into something unexpected (for me) regarding file permissions on Linux (Arch Linux). Basically I have: userX in groupX fileX userX:groupX ---rwx---- What puzzles me: I cannot perform ...
1
vote
0answers
19 views

Configuring group access across a LAN

I have created a group called engineers on two VMs on the same 192.168.56.0/24 LAN. Is there any way the members from VM1 in engineers can view files created by engineers from VM2? I was thinking of ...
33
votes
6answers
15k views

Howto find duplicate files on disk

Is it possible to find duplicate files on my disk which are bit to bit identical but have different file-names?
0
votes
1answer
35 views

file command to show “for GNU/LINUX 2.x.x” also for shared libraries

Using the command file my_executable_binary I get information like this: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.34, dynamically linked (uses shared libs), stripped ...