Use this tag for questions about file management and operations on files.
7
votes
2answers
163 views
Cleaner way to delete files on Linux which include a datestamp as part of file name
I have a new requirement to purge MySQL dump files that are older than 30 days. The files use a naming convention of "all-mysql-YYYYMMDD-HHMM.dump". The files are located on SAN mounted file system, ...
1
vote
1answer
30 views
Error writing /home/alessiomtx/.config/tint2/tint2rc: Not a directory
I need to edit my ~/.config/tint2/tint2rc because the file is blank and so I don't have tint2 shown in my desktop, but when I try to save I have this error:
[ Errore durante la scrittura di ...
4
votes
2answers
321 views
Find and remove large files that are open but have been deleted
How does one find large files that have been deleted but are still open in an application? How can one remove such a file, even though a process has it open?
The situation is that we are running a ...
0
votes
0answers
19 views
no such file or directory [duplicate]
I have a 64-bit Ubuntu and want to execute a 32-bit FreeRTOS binary. The error message says no such file or directory. The files are there I can read them with ls -l.
0
votes
1answer
122 views
how are directories implemented in UNIX filesystem?
This question is extension to How are directories implemented in Unix filesystems?
I'm aiming to implement basic filesystem: After reading inode number and name we come to know Name of file and hence ...
1
vote
2answers
95 views
Merge a number of text files into one with next line for every file
I have 2 files. I want to merge them.
File1 contents:
abc
File2 contents:
def
Combined File should be:
abc
def
0
votes
1answer
48 views
Rsync adding a “?” at the beginning of directories
I currently have many of these commands running in a .sh file that looks like this:
rsync -avz -e ssh --rsh='ssh -p1337' --bwlimit=10000 root@DestinationIP:/home/backup /home/localbackup
rsync -avz ...
1
vote
2answers
74 views
Cannot access any files Manjaro Linux
I cannot open any files on my Manjaro Linux laptop. I really can't remember why it happened but I restarted my computer and now I dont have read/write access to any folder or file even though I've ...
1
vote
2answers
107 views
A bunch of files have 777 permissions
I have been learning Python and Bash scripting, and I up to now I have given my scripts 777 permissions. Having learned more about how to set permissions, and knowing this is a bad idea, I ran the ...
2
votes
1answer
38 views
Better way to copy multiple directories to new directory
Is there a better way on the command line to essentially accomplish the following but with a single command
cp -r css/ ar/
cp -r images/ ar/
cp -r js/ ar/
cp -r backups/ ar/
I've just been ...
4
votes
5answers
138 views
Delete files in directory without erroring if it's already empty
As part of a deployment script, I want to dump some cached stuff from my temp directory. I use a command like:
rm /tmp/our_cache/*
However, if /tmp/our_cache is empty (fairly common when pushing ...
3
votes
4answers
168 views
Piping output to text file within a for loop
I'm trying to do the following within a for loop:
Find files that satisfy a condition
Echo the name of the files to a log file.
Gzip the file.
I can get the script to find the files and echo their ...
11
votes
4answers
282 views
Is there a top-like command that shows the network bandwidths and file accesses of running processes
For example, we'd like to see:
PROCESS IF TX RX FILE(regular) R/W
prog1 eth0 200kB/s 12kB/s -- --
wlan0 12kB/s 100kB/s -- ...
16
votes
2answers
738 views
How do I make a file NOT modifiable?
While logged in, I can do the following:
mkdir foo
touch foo/bar
chmod 400 foo/bar
chmod 500 foo
Then I can open vim (not as root), edit bar, force a write with w!, and the file is modified!
How ...
2
votes
4answers
304 views
Move all files with a certain extension from multiple subdirectories into one directory
Suppose I have a bunch of zip files in several directories:
Fol1/Fol2
Fol3
Fol4/Fol5
And I want to move them all to a common base folder. How would I do this?
0
votes
0answers
97 views
Log4j File Location
I have a Webapp running on an Amazon EC2 Linux AMI. I've been trying to configure my Log4J file for logging but haven't been able to figure out where the logs are getting created.
This is my log4j ...
1
vote
1answer
29 views
Can one move a relpath in one command?
This question is similar to one I asked recently, but the answers to that question, for the most part, do not extend to this one, AFAICT. The main difference between the two questions is that the ...
1
vote
2answers
73 views
Create a virtual file that is actually a command
Is there any way to create a virtual file, such that reading from the file actually reads from the stdout of a command; writing to the file is acually writing to the stdin of a command?
So far I have ...
1
vote
2answers
91 views
Can one copy a relpath in one command?
I find myself doing this often enough that I wonder if there's a standard Unix way to do it:
% mkdir -p /TARGETDIR/relative/path/to
% cp ./relative/path/to/somefile /TARGETDIR/relative/path/to
In ...
1
vote
1answer
61 views
How to find undeletable files that were removed?
I just created a file:
touch myFile
Made it "undeletable":
chattr +u myFile
and removed it:
rm myfile
How can I get it back? What is the purpose of "u"? Is it used?
1
vote
1answer
222 views
`ls` command does not list latest directory contents
The Linux shell does not print up-to-date information when it comes to ls. For example I use my other processes (IDEs etc) to create some directories. However when I run an ls command I don't see ...
2
votes
2answers
56 views
Select greatest numbered filename
Simple requirement but can't find anything online which can achieve it.
I have a list of dated files as below...
filename_20120101.dat
filename_20120102.dat
filename_20120103.dat
I ...
3
votes
2answers
151 views
How to write file into another
I have an empty file (only zeroes are in it) of size 9,0KB and I need to write another file (with size 1,1KB) to it, but the first file must not lose its size or the rest of its contents. So if the ...
0
votes
1answer
73 views
Debian VirtualBox Guest - Common Files to Remove for Space Saving?
I have created a VirtualBox guest using debian-6.0.7-amd64. I am using it as a clone template to create Java work nodes, so my needs are pretty much limited to the JVM, networking, SSH and the basics ...
2
votes
3answers
90 views
How does gcc handle file permissions?
The executable files that gcc creates have execution permissions
-rwxrwxr-x
which are different than the permissions that the source file has.
-rw-rw-r--
How does gcc set these permissions ?
2
votes
1answer
244 views
Create sub-directories and organize files by date
I have some directories of files copied from my security camera that I would like to organize into sub-directories by file date. So for example;
-rwxrwxrwx 0 root root 4935241 Jul 19 2012 ...
3
votes
4answers
180 views
Using GNU Parallel With Split
I'm loading a pretty gigantic file to a postgresql database. To do this I first use split in the file to get smaller files (30Gb each) and then I load each smaller file to the database using GNU ...
4
votes
8answers
150 views
Run a command on all subfolders
If you have a series of subfolders (like from a to z) and want to run a command on each one of them (like rm *.pdf or ls *.pdf), how do you do that? The "manual" approach would be cd a, rm *.pdf, or ...
1
vote
0answers
36 views
Existing file can not be found? [duplicate]
/usr/share/tipp10$ ll
insgesamt 9408
drwxr-xr-x 3 myname ssl-cert 4096 Feb 26 20:07 ./
drwxr-xr-x 288 root root 12288 Feb 26 20:07 ../
-rwxrwxrwx 1 myname ssl-cert 9480 Okt 6 2010 ...
3
votes
3answers
90 views
Control how linux deletes files
What exactly happens when an application deletes a file?
Is there any way to control this behavior? Basically I want to shred instead of rm in all cases, but of course applications do not make calls ...
1
vote
1answer
94 views
reading from a file and changing its pattern into an array?
I have a CSV file containging entries like this :
ipaddress,VLAN,VLANid
10.192.168.1,vlan-xyz,3
10.192.168.1,vlan-abc,8
10.192.168.1,vlan-mnp,11
10.192.163.24,vlan-llz,3
10.192.163.24,vlan-bbz,5
...
1
vote
4answers
67 views
How to find what device a file is on (and use that in a script)?
I want to find out what device my file is on so that I can use it in a script. I can get this far:
$ df .
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk0s2 498438976 ...
-1
votes
2answers
86 views
What is sources.list?
I know sources.list is a file that contains a list of HTTP links pointing to some software downloads.
I would like to know more detailed explanations and various conventions followed in the ...
2
votes
1answer
81 views
How can I identify the total files open by userid
Yesterday one of the users on our system had a poorly formed script that consumed all the space in one of our file systems. Through a lot of trial and error, I was able to identify the user and kill ...
0
votes
2answers
176 views
Solaris 10 modified time
In Solaris 8, when we access the file, the access time changes but modified time remains same. But in Solaris 10, we see that both access and modified time changes when accessing the file. We checked ...
0
votes
1answer
76 views
How hardlink and softlink works in background?
I am looking for an explanation of the following:
what happens in Linux when we create soft link and hardlink
how are they accessible
why do symlinks always display 777 permissions
3
votes
4answers
118 views
Most Efficient way to back up/sync large directories over SSH
I'm looking to back up some large directories on a Dedicated Server to another Server on a daily basis using minimal bandwidth
RSync looks like its up to the task but I'm unsure of the best command ...
1
vote
1answer
131 views
File is readable by everyone, but I can't open the file
I'm fairly new to Unix and I have written a script:
SERVER="/usr/local/abc/.../somefile.txt"
OPTION="$1"
if [ x$OPTION = "xtitle" ]
then
grep $OPTION $SERVER
exit
fi
As far as I ...
0
votes
1answer
78 views
Having trouble executing a compiled C program
I am running an Ubuntu v10.04 through VirtualBox. To test the persistence of files I create in the virtual machine, I wrote a very basic C program. When I shutdown the virtual machine and restart it, ...
0
votes
0answers
56 views
File size conflict
I am new to unix and have a doubt about file size in Unix.
ls -ltr shows me fileA size as 59096.
As per my knowledge this is in bytes ,so it is nearly = 0.06MB
However, a script which should zip files ...
2
votes
2answers
90 views
Matching two files for similar first line
I have 2 set of files.
File one contains ID's
ex:
1111
2222
6666
3333
4444
File two contains ID and username:
1873 Neil
1111 Roger
7632 Tim
3333 Oscar
8723 Greg
4444 Roy
6666 Patrick
I want to ...
2
votes
2answers
71 views
A command line utility to visualize how fast a file is growing?
I want to grok how fast a particular file is growing.
I could do
watch ls -l file
And deduce this information from the rate of change.
Is there something similar that would directly output the ...
2
votes
3answers
67 views
How to prohibit from changing an owner of modifiable files?
I sometimes need to run a Qt Creator from root. After that, some config files of Qt Creator suddenly have a root as an owner. Therefore when running Qt Creator as user, I am getting nag warnings about ...
2
votes
2answers
141 views
dynamic file system with hooks
Is there anyway in linux (I don't care which distribution or flavor) to have a dynamic file system with read/write hooks? For example I would like to mount a dynamic file system at /dynamic and ...
3
votes
2answers
185 views
Get the complement of the result of an ls command
Let's say I have a directory with multiple files, all of which are either binary files (files with no declared extensions) and source files (.c extension). I do this:
$ ls
and get:
README.md ...
2
votes
2answers
143 views
Pseudo files for temporary data
I often want to feed relatively short string data (could be several lines though) to commandline programs which accept only input from files (e.g. wdiff) in a repeated fashion. Sure I can create one ...
-2
votes
3answers
137 views
Determine whether a particular file is compressed
How to know in Linux whether a particular file is compressed or not using a command?
3
votes
4answers
99 views
Unix - how to fetch files based on the part of a filename that is date
Say I have files say like
AA_XX_20111208
AA_XX_20111207
AA_XX_20111206
AA_XX_20111205
AA_XX_20111204
AA_XX_20111203
So using the date part,
how can i fetch previous 2 month files ?
For e.g. this ...
1
vote
1answer
342 views
Reading the contents of the file and splitting using ksh
We're using a ksh script for installing one product.
I've another config file, I'd need to read this configuration file from my main script
Content of the Configuration file:
...
2
votes
3answers
72 views
How to cp or rm files based on ownership / permission
After a problem with spam, I stopped postfix
postfix stop
and checked through the mailq manually to find hundreds of thousands of unsent spam.
The spam was sent from one of the sites hosted ...

