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

learn more… | top users | synonyms (1)

2
votes
4answers
68 views

Get the latest directory (not the latest file)

My folder parent has the following content: A.Folder B.Folder C.File It has both folders and files inside. B.Folder is newer. Now I just want to get B.Folder, how could I achieve this? I tried ...
12
votes
5answers
13k views

How to list all files in the size order

I would like to list all files in the order of big to small in size and the files could be present anywhere in a certain folder.
0
votes
3answers
58 views

Looping the listing files in UNIX

I've given the command: ls -lrt and the listed files and directories are: drwxr-xr-x 4 root root 4096 Feb 2 2014 abc drwxr-xr-x 4 root root 4096 Feb 2 2014 cde drwxr-xr-x 4 root ...
3
votes
1answer
51 views

Protecting data against bit rot

I have realized that I need to protect all of my photographs against bit rot (file corruption occurring at random due to errors in hard drives or network transfer). I recently discovered par2 which ...
11
votes
3answers
542 views

Read the middle of a large file

I have a 1 TB file. I would like to read from byte 12345678901 to byte 19876543212 and put that on standard output on a machine with 100 MB RAM. I can easily write a perl script that does this. ...
1
vote
2answers
70 views

Copying the newest files

We have a script running which picks up the report generated monthly on remote servers. I was trying to find a way to pick up the latest file from the remote servers only. Will find work in script ...
2
votes
5answers
498 views

How to use the sed command to only show the first column and last column in a text file

I need some help to figure out how to use the sed command to only show the first column and last column in a text file. Here is what I have so far for column 1: cat logfile | sed 's/\|/ /'|awk ...
3
votes
1answer
259 views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
2
votes
1answer
31 views

updatedb for a beginner

The updatedb command, as I understand it, is basically the utility that keeps the mlocate.db database file updated. And it's a good idea to keep it updated regularly. For that matter, I've kept a ...
0
votes
1answer
25 views

Mount a file collection in a linux environment

I am presently working as a summer intern. My first objective is, given a collection of files, recover and identify the file types present in it. To download sample pseudo-forensics data I have been ...
11
votes
1answer
423 views

How is file owner and group remembered for an external drive?

I formatted an external hard drive with an ext4 partition and subsequently mounted it. So that I could use the new partition, I did: sudo chown me:me /mount/directory to change the file owner and ...
3
votes
3answers
56 views

Moving an open file to a different device

I have an application running that is generating a large (~200GB) output file, and takes about 35 hours to run (currently I'm about 12 hours in). The application just opens the file once then keeps it ...
3
votes
2answers
67 views

Error when calling mv with wildcards

#! /bin/bash error_text=$(tail -n +1 /path/dir/folder/exc/a/update/Abd/ER/* | \ grep 'Warning\|Loaded\|Event') echo $error_text nc 10.10.99.45 25 << EOF ehlo mail.abc.pvt mail from: ...
4
votes
3answers
126 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 ...
0
votes
1answer
27 views

setfacl remove all write access

I want to remove all write access to files & directories for any user or group while preserving other permissions. Is this possible?
1
vote
1answer
24 views

console (driver) not opening using any of the editor

In my initramfs, I have; [root@xilinx Peta_Microzed_15_05]# ls initramfs/dev/ console [root@xilinx Peta_Microzed_15_05]# nano initramfs/dev/console [root@xilinx Peta_Microzed_15_05]# The above ...
1
vote
2answers
407 views

Remove first instance of lines with duplicate field value

I have sha1 summed all the image files on my storage server and put the results in a text file in the form of: sha1sum filename I've sorted the file and removed all all unique sha1sum entries. So ...
2
votes
2answers
87 views

inotifywait different action on file or dir

I'm trying to make a inotifywait script take different actions for files vs folders if it sees a close_write flag being raised in the watched directory, but cannot seem to get the checks working. In ...
15
votes
2answers
1k views

Create a test file with lots of zero bytes

I know how to create an empty file: touch /var/tmp/nullbytes but how can I create a 1MB file that only contains nullbytes on the commandline with bash?
12
votes
3answers
318 views

How to check whether file1 is a prefix of file2?

I have two files with sizes 124665 and 124858 in bytes and want to check whether file1 is a prefix of file2 or not.
4
votes
2answers
186 views

Is there a command line method by which I can check whether a downloaded file is complete or broken?

I'm writing a script that involves downloading and manipulating a file, and I want to ensure that the file is not incomplete (due to e.g. a dropped connection) before I work on it.
1
vote
2answers
33 views

List of files accessed by application

I want to install propertiary AMD driver but I would also like to know which files were created/changed by installer. Is there some application which can observe (probably by inotify) which files were ...
4
votes
4answers
157 views

What is the Linux command to display how many file names in the directory end in two digits

What is the Linux command to display how many file names in the directory end in two digits? Using ls with a command like this : ls -l | wc –l *[0-9][0-9]
1
vote
2answers
112 views

using inotify to monitor access to a file

I would like to have a trigger and when a particular file is accessed by some process, I would like to be notified (i.e. a script should be run). If I understand correctly, this could be achieved with ...
1
vote
2answers
83 views

Sort files into directories named by prefix of file

I have a bunch of files like this 5830_1.png 5830_2.png 5830_3.png 5831_1.png 5832_1.png 5832_2.png I'd like to sort these files all into directories that take the prefix of the file name as the ...
0
votes
2answers
97 views

Linux - Delete last two files automatically

In Linux, one folder is created every morning and 5 files are created in that folder. At the end of the day (Midnight), the last two files in that folder have to be deleted. How can I accomplish ...
5
votes
3answers
347 views

Linux command to return all files that start with TEMP but do not end with double digits

What is the Linux command to return all files that start with TEMP but do not end with double digits? I think it should look something like this: ls -l TEMP*[!0-9][!0-9] but the results of my ...
3
votes
5answers
119 views

Look if a folder has some files of certain extention

Lets say I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and look if they have any .pdf files. Could some one please ...
4
votes
2answers
87 views

Linux File Permissions Enforce Order

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
1answer
44 views

Why won't my system now show the directories and files in /media/sda7?

Summary: Could you tell me please if there is a way to restore the directories and files beneath /media/sda7 that are no longer being shown by my file manager or ls? My system is Debian. Full ...
1
vote
2answers
66 views

Shell script to Capture the file name and size in csv file and add header on that file

I have a number of zip files in a certain folder. I want to capture file name and the size of the files in a CSV format in day wise and put it in crontab so I can report on a daily basis, and then ...
0
votes
1answer
64 views

How do I create a RAM disk on Linux Mint?

I am running a package that adds data to the end of 140–300 files each time through the process. I'm thinking of moving the process to a RAM disk, and using rsync to copy it back when done. My goal ...
5
votes
4answers
322 views

Check if a folder has a certain type of file present

How could I check if a file has a file of extension .java? So far I have: for javaFile in *.java ; do { echo "The file $javaFile has : " >> ~/Desktop/externalServers.txt ...
2
votes
2answers
153 views

Any way in Bash to write to a file every X seconds without closing it?

The hardware watchdog on my system needs a 0 written to /dev/watchdog at less than 60 seconds interval or it will fire. The file handle must be kept open however or the watchdog is then disabled. ...
0
votes
1answer
136 views

Transfer files from CentOS VM VirtualBox to Windows host machine

How can I transfer the scripts and text files I've created in my CentOS environment and put it in my host desktop (Windows 7)? I've tried using ftp but it needs to configure the routers to use vsftpd, ...
19
votes
4answers
1k views

Is there an “open with” command for the command line?

Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a .pdf file would have an open with... recommendation using ...
5
votes
2answers
55 views

How to backup dir structure ignoring files & dirs without read permission

Any ideas how to back up a directory structure for which there are some files and/or directories for which you do not have permission to read? I'd like to just ignore those, without backup (tar? jar?) ...
3
votes
2answers
211 views

Read all files in folder and subfolders - progress and size

Command I have is: time find . -type f -print -exec cp {} /dev/null \; This command finds all files in current folder and subfolders, print the name of each file and copy each of them to /dev/null. ...
2
votes
1answer
50 views

what is the original command to create a file? [closed]

we can create a file by a lot of commands: cat > foo.txt echo 'This is a test' > foo.txt touch foo.txt vi foo.txt (or any text-editor) my questions are: What is the original command to ...
1
vote
1answer
41 views

Emacs, complete list of color “keys”

If you want to customize the colors in Emacs, specifying them in the .emacs init file, without installing any extra package, and without using a pre-made theme, something like this seems to work: ...
2
votes
2answers
69 views

how to show total files size in a folder by filtering extension without showing each file size

du -hc *zip shows me total size of zip files in a folder, but it shows also every single file size of the folder. I only need total size. Is there way to show the total size of a folder without ...
7
votes
5answers
5k views

How to copy directories with preserving hardlinks?

How to move directories that have files in common from one to another partition ? Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks. How to move such ...
13
votes
3answers
5k views

List the files accessed by a program

time is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can list the files being accessed by a program and its children. ...
3
votes
3answers
179 views

Shell script to replace string in multiple files within selected directories

I created the script below which takes the path of a single directory and replaces search string in all the files within that directory. I would like to enhance this script in such a way that it can ...
1
vote
4answers
106 views

How do i get the latest file from a list of files in a particular directory

I need to get the latest file from a list of files in a particular directory. When I run the script the first time I've copied the list of files in a particular directory to another directory. From ...
0
votes
1answer
43 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 ...
6
votes
5answers
628 views

Is there a way in Linux to have one non root user check if another non root user has permissions to a folder / file?

The scenario is this - I have a command line program that might not run as root, part of the requirements is to warn if another user has write permissions to some folder / file e.g. I'm running as ...
0
votes
1answer
43 views

Partition is out of space

When I was trying to resolve the issue as seen in this question, I figured out that a specific partition is out of space. I have a specified folder which I allow all ftp uploading of multimedia files ...
2
votes
0answers
25 views

Image set compression

Is there a good open source (not exclusive to Linux) for compression of a set of similar images? I have thousands of documents scanned but I do not access them often. The documents are forms, with ...
-2
votes
2answers
39 views

Clarification on permissions with GID & UID in UNIX

If Test1 & Test2 are users, then Test1 : UID : 501, GID :501, groups=501,100 Test2 : UID : 502, GID :502, groups=502,100 What will be the correct option from below and explain how? Test1 ...