Use this tag for questions about file management and operations on files.
0
votes
0answers
2 views
A question about Linux permissions
I have a USB flash drive with ext4 file system and its files are owned by my user on my local machine, for example by myuser@myhost with 700 permissions.
If I unplug my flash drive and plug it in ...
1
vote
2answers
32 views
Delete files except n files with the “bigger” name?
I want to create a shell script that deletes old release files except last n files. In other words, only mantain last n releases when I deploy a new release.
File names have this format:
...
6
votes
1answer
42 views
How to redirect stdout and stderr to a file and display stderr to console?
I know how to redirect to a file, and use tee; on a basic level.
So
$ alias outanderr='bash -c "echo stdout >&1; echo stderr >&2"' \
# A fake "application" displaying both output and ...
2
votes
3answers
57 views
determine user-modified files
I plan to reinstall my operating system since I messed up some stuff. Access to files and folders is painfully slow sometimes, even if they contain just a few files.
But of course, I don't want to do ...
1
vote
3answers
92 views
Test if there are files matching a pattern in bash
I am trying to write an if statement in bash to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.
My code currently
if ...
4
votes
3answers
110 views
How can I get rid of this invisible file?
Background
I have a folder named akorgā½. That Unicode character causes headaches for me when software makes incorrect assumptions about the text encoding of my file paths, so I'd like to remove it ...
2
votes
1answer
59 views
NFS permission denied
When I configure NFS and create a file on the client NFS shared dir, I get the following message: permission denied.
My configuration:
configuration nfs server
...
1
vote
0answers
24 views
Reformat terminal output and save to file
I was wondering how to reformat terminal output for logging information. More specifically I would like to reformat the output of the sensors command from the lm-sensors package and write it to a ...
0
votes
1answer
65 views
What disk is a file / directory stored on? [duplicate]
From the command line (bash) I would like to know what disk a given file is stored in. E.G.:
$ [what filesystem is this file in command] /tmp/example/file
/dev/sda1
2
votes
3answers
57 views
Replace filename with parent folder name
I have a bunch of files each in their own subdirectory. I need to write a script to rename each file to have the same name as its directory: For example, given:
./1111/1234.pdf
./2222/2345.pdf
...
14
votes
3answers
697 views
How does touch -t work internally?
How does touch -t command works exactly, internally (I tried to find its source code but couldn't)?
3
votes
0answers
73 views
Move files and delete directories with rsync?
Recently I needed to delete a large number of files (over 1 million) and I read that doing:
rsync -av --delete `mktemp -d`/ ~/source && rmdir ~/source
Was one of the most optimized ways to ...
1
vote
2answers
54 views
How can find support large files?
I would like to find all the files of my system, which sizes are more than a couple gigabits. I thought I would use find -size, but the man page states:
The size does not count indirect blocks
...
0
votes
1answer
97 views
Simple bash script taking too long to execute
I wrote the following function in my .bashrc for use instead of rm * :
function re()
{
cp . -R /home/glset/ritwik/trash/
rm *
}
It works .. but it is very slow. Even for small files it takes too ...
3
votes
2answers
46 views
Test if a file is on NFS?
Is there a simple test to determine if a file is on an NFS mount? (Or maybe more generally, what type of filesystem a file lives on?) I am imagining some ugly prefix matching against fstab...
5
votes
2answers
57 views
Disk usage summary per user
Is there a way to get the disk usage per user under a given path? du doesn't seem to have an option to aggregate disk usage per user, and df only seems to report how much disk is left on the drive.
...
2
votes
2answers
47 views
Unable to concatenate files with find ./subdir/* -print0 | sort | xargs -0 cat > merge.txt
I am trying to concatenate thousands of files that result from processing the pieces output by split with
find ./subdir/* -print0 | sort | xargs -0 cat > full_merge.txt
The files under subdir ...
0
votes
3answers
51 views
What does ./ mean? [duplicate]
I'm having a hard time getting what ./ does.
In the Linux Essentials books, it asks me in an exercise to delete a file named -file. After googling, I found that I need to do rm ./-file but I don't ...
4
votes
4answers
68 views
How to split a file by using keyword boundaries
I have a vcf file that contains numerous vcards.
When importing the vcf file to outlook it seems to only import the first vcard.
Hence I want to split them up.
Given that a vcard starts with
...
2
votes
1answer
46 views
Strange changes in files
I have a very strange problem on one of my servers. I'm not sure if it's completely related to linux because it occurs in php and js files.
Today I was trying to backup my databases using phpmyadmin. ...
2
votes
2answers
86 views
Linux listing files between two date without touch command
I need a command which will list the files between given date and time (YYYYMMDDHHMMSS - format) in to a text file.
I don want to use touch command as its creating permission issue.
I am new to this ...
2
votes
4answers
49 views
find command: how to ignore pathname?
I have to find some type of files in a directory and it's subdirectories and I only have to print out the filenames.
So here's the main command:
find -type f -name "*.c"
Now, how could I cut the ...
4
votes
3answers
59 views
Dynamic file content generation: Satisfying a 'file open' by a 'process execution'
I have a read-only file, F.
A program, P, that I'm not the author of, needs to read F.
I want the content of F to come from another 'generator' program, G, whenever P tries to read F (taking F to ...
0
votes
1answer
30 views
Keyboard shortcut to switch files in one Emacs instance?
I've multiple files opened in an Emacs client. Right now, to toggle between files, I've to click on the file name at the bar below in the editor. Any keyboard shortcuts for switching between files?
0
votes
0answers
32 views
Creating and writing to an UTF-8 file with C++ [migrated]
I have to create a m3u8 playlist in my http streaming C++ server code. m3u8 is nothing but UTF-8 m3u file.
How do I create an UTF-8 file (i.e. how to write UTF-8 characters to a file)? Maybe with ...
20
votes
1answer
485 views
How to move a directory, file by file? (instead of “copy then remove”)
My computer has one 500GB drive.
I want to move 400GB of data from /unencrypted to /encrypted.
Both directories are on the same partition, but /encrypted is handled by ecryptfs, so mv /uncrypted/* ...
2
votes
4answers
131 views
Find and copy directories containing file type
I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc.
I'm trying to copy all directories containing ...
2
votes
1answer
63 views
how to keep file owner same for newly created files
This question is regarding samba file access.
I have created a folder A, and under folder A created two folders B and C. And also created three users A, B and C.
User A has access to all three ...
4
votes
1answer
75 views
Can I create a symlink that will ignore subdirectories?
I'm trying to get dropbox symlinked to the relevant folders in /home. I'd like to symlink them like this:
~/Dropbox/Pictures --> ~/Pictures
~/Dropbox/Camera Uploads --> ~/Pictures/Camera ...
1
vote
1answer
39 views
Getting back rsync's deleted files [duplicate]
I accidentally rsync-ed to a server using the delete attribute when I shouldn't have.
Is there any chance of getting the data on the server that rsync removed.. back?
3
votes
3answers
133 views
How to move all files with a certain file extension from subdirectories to a single directory
I have a directory that contains many subdirectories. The subdirectories contain lots of types of files with different file extensions. I want to move (not copy) all the files of one type into a new ...
1
vote
1answer
64 views
Standard I/O File Descriptors
I am new to Shell SCripting
I code this
$ ls -l 1> stdout.txt
and I get the output as desired,
1> stdout.txt
redirects the output from standard output to the file stdout.txt.
I don't ...
3
votes
2answers
58 views
Search by file dimension [duplicate]
I have many photos. How to search files by its dimensions? For example, i want to search images with exact dimensions 500 x 500 pixels. Is there any utility for this task?
1
vote
2answers
32 views
Single process accessible temporary file
I want to create a file that is only accessible to the process that created it (and potentially its children), and that disappears when the process exits, ideally never persisting the file to disk. As ...
2
votes
2answers
114 views
How does Linux know the Location of File Data on Disk
related to: What is a Superblock, Inode, Dentry and a File?
None of the famous metadata structures hold onto to location data for the actual file. Dentry maps names to inodes, and inodes store ...
0
votes
2answers
140 views
Redirecting stdin with stdout to file
So I have a program that takes in user input and outputs text based on the input.
EDIT2: I want to create a script that runs a C executable and the script feeds the C program input from a file and ...
0
votes
3answers
110 views
how to delete temp and log files with terminal on vps?
I'm kinda pretty new to this but anyone know how to delete any temp and log files or these kind of files on vps with terminal? I'm runnin debian on the vps. I'm troubled since I can't locate those ...
4
votes
2answers
90 views
How to upgrade shared library without crash?
Here it says that you can rewrite an executable file and the process will run just fine - it will be re-read when a process restarts.
However, when I try to replace a binary file while the process is ...
27
votes
2answers
1k views
Why does a software package run just fine even when it is being upgraded?
Say I am running a software, and then I run package manager to upgrade the software, I notice that Linux does not bring down the running process for package upgrade - it is still running fine. How ...
0
votes
1answer
51 views
LINUX: Permissions for files: Identify if it is a file or directory, and its access allowed to the world, user, and group [duplicate]
I am having trouble understanding permissions for directories and files in LINUX.
By examining permissions for each of the following files, identify if it is a file or directory, and describe the ...
6
votes
1answer
118 views
find is missing a result — how is that possible?
What conditions explain this output:
root@ip:/# find / -name "server.xml" -print
/etc/tomcat7/server.xml
root@ip:/# ls /var/lib/tomcat7/conf/server.xml
/var/lib/tomcat7/conf/server.xml
I am ...
4
votes
3answers
64 views
Replace all the occurences of a term in the files contained in a folder
In a folder on my system, I have a C++ project that I'm trying to compile.
This process uses some C++ idioms which are not supported by my compiler version. In particular, often inside the code it is ...
6
votes
4answers
229 views
How do I stop the root user from deleting a file?
I'd like to know if I can prevent the root user from deleting a file.
Is it possible?
1
vote
1answer
57 views
Program for identifying files from unfinished torrent-downloads?
Are there any programs that can help identify files and directories belonging to unfinished bittorrent-downloads? I've made a mess, and I'm unsure of which downloads are finished and which are not. ...
1
vote
2answers
150 views
Any programs suitable for making a database over disk-content?
I have quite a lot of external hard-drives, and often have a hard time finding what I'm looking for - not to mention not storing the same file several times on different drives or finding free space ...
2
votes
3answers
141 views
file mass deletion
I would like to delete all the txt, xls,pdf files in a directory as well as its sub directories. I would like to save everything else.
find . -type f ! -iname '*.xml$,.png$,.jpeg$,.gif$,' -delete
...
3
votes
2answers
87 views
How can I backup a directory to NTFS while preserving Unix file attributes?
I want to make a backup of my home directory to an NTFS partition (an unfortunate limitation). However, when I last tried using just cp, the attributes (owner, etc) went away. How can I make a backup ...
2
votes
1answer
134 views
Script to check a folder, print the files then delete those files
I am looking for some guidance on creating a script that will check a specific folder, print all documents (if any) and then delete those documents. I would also like to run this script as a cron job. ...
0
votes
1answer
252 views
Transfer 150GB of files from an old MacBook Pro with Ubuntu 13.04 Live DVD
My girlfriend's old MacBook Pro 2009 (5,4) stopped working. I have tried several times to reinstall OS X, but could not do so. There appears to be something really really wrong with the OS.
Since she ...
2
votes
1answer
105 views
“rm -rf Filename.iso ” Permission denied
Hi I am facing an issue while deleting an .iso file from Linux x86_64 GNU/Linux.
Here are the permissions for the file:
# ls -lrt
-rwxrwxr-x 1 dev devgrp 2687934464 Apr 12 14:13 ...



