Questions tagged [files]

Manipulating files: copying, renaming, searching, analyzing, archiving, etc. For operating on text in a file, see /text-processing. For questions about the Files file manager (formerly Nautilus), see /nautilus.

Filter by
Sorted by
Tagged with
38
votes
6answers
130k views

Cannot remove file: “Structure needs cleaning”

I have an external hard drive which is encrypted via LUKS. It contains an ext4 fs. I just got an error from rsync for a file which is located on this drive: rsync: readlink_stat("/home/some/dir/...
1
vote
3answers
55 views

Sorting and copying files

I am newbie here, please be patient. I have a directory containing thousands of files. Filename always start with 1 or 2 letter and have 4 character before underscore "_". The number of ...
1
vote
2answers
22 views

rsync files across multiple user accounts

I am quite new to using rsync and I'm wondering if it is possible to rsync files across multiple user accounts on a single PC? For the computers I want to apply the rsync command to, each user has to ...
0
votes
1answer
10 views

How to compile lines with a certain word in the last column into a separate file?

I have a csv file and I need to filter it out into two files based on whether the last column contains the word "ecDNA". I already have two more copies of the file to edit without changing ...
0
votes
2answers
59 views

What does mounting do in Linux and why do files appear in both /dev and /media after mounting?

I'm pretty new to Linux and I've been trying to understand how the file system works but I just can't seem to get what mounting is. I've seen several other questions on this site explaining but they ...
118
votes
7answers
54k views

How are “/dev” Linux files created?

There are special files in Linux that are not really files. The most notable and clear examples of these are in the dev folder, "files" like: /dev/null - Ignores anything you write to the file /dev/...
0
votes
1answer
86 views

Regex for a non-fixed pattern

I am trying to come up with the right regex (compatible with python) that would match a file that contained sample input as follows: On the third day of Christmas my true love sent to me: three ...
0
votes
0answers
36 views

How to reuse shell arguments with pipes [closed]

I want to write a shell script baz.sh to which I pass (text) file: baz.sh < file Where baz.sh is some thing like #!/bin/sh foo=$(head $1 | grep "foo") bar=$(head $1 | grep "bar"...
0
votes
2answers
83 views

Can not change the user owner of a file

I'm running Ubuntu under Windows. I have a file which is owned by a user named leon: -rwxrwxrwx 1 leon leon 0 Jun 8 20:25 linux1.txt but for some reason, I can't change its owner by running (...
2
votes
2answers
29 views

In a file to find and replace/change multiple strings in a line with shell script

I am new to shell scripting What I have is a log file, each line begins like the below entry, [2021.04.27.17:03:43.813]: ERROR - [2021.04.27.17:04:36.790]: SUCCESS - The desired output to a new file ...
0
votes
2answers
55 views

bash: Read from stdin until a string delimiter

Let's say I have two files containing arbitrary bytes: ./delimiter and ./data. I want to read from ./data up to and excluding the first occurrence of the byte sequence in ./delimiter. How would I do ...
2
votes
0answers
25 views

Tool for clearing build directories (different programming languages/frameworks)

Aside from writing own scripts, is there some kind of CLI tool that can scan target folders or volumes and delete build artifacts or recreatable dependencies with support for different programming ...
2
votes
1answer
1k views

Locate and manage files on extern hard drive through FileZilla over SSH

I have installed Debian Server on one of my servers and plugged in a extern hard drive to it through USB (sdb1, 2, and 5 on the image below) where I have all my files on right now. Before I used this ...
11
votes
8answers
9k views

sed in-place line deletion on full filesystem?

Due to an application bug as yet undiagnosed, I have several hundred servers with a full disk. There is one file that has been filled up with duplicate lines—not a log file, but a user environment ...
0
votes
2answers
78 views

How to limit the number of files in a directory?

Is it even possible to limit the number (and not the size) of files in a specific directory? My directory only can contain up to five files, and cp file_6 mydir must not be allowed.
3
votes
2answers
93 views

Parent child directory same name , move files to parent directory

I need a way to search directories for child directories with the same name and then move all files in the child directory to the parent. Thus from /recup-dir1/recup-dir1/files to /recup-dir1/files. ...
24
votes
3answers
22k views

viewing dll and exe file properties/attributes via the command line

I have a need to see some additional file properties for exe and dll files. If I open windows explorer and add the additional columns to my view, I can see things like Company, Copyright, Product ...
1
vote
1answer
164 views

Files holder application like dropover and yoink for Mac

I've recently switched back from macOS to Linux Mint. The only thing I miss about Mac is having a utility that could hold my files for copying and pasting while I switch between the desktops. Yoink ...
2
votes
1answer
24 views

How can I move files to different directories depending on their contents?

I have many files which contain a string like this: /databis/defontis/Dossier_fasta_chrm_avec_piler/SRR6237661_chrm.fasta: N putative CRISPR arrays found Where the N is a number that can be either 0 ...
2
votes
1answer
27 views

Reading stale file data with debugfs cat

I'm trying to read the contents of a file using the file's inode. This works fine: echo "First line" > data.txt sync sudo debugfs -R "cat <$(stat -c %i data.txt)>" /dev/...
6
votes
4answers
1k views

In Linux, is there a system layer/script that handles the opening of files?

in Linux, is there a layer/script that handles program-requests to open files? Like when you open a file-descriptor in bash: exec 3 <>/documents/foo.txtor your text-editor opens /documents/foo....
1
vote
1answer
92 views

How does the OS access files stored on the hard disk?

I know the first thing the OS accesses on the harddisk is the superblock. But then what?
4
votes
1answer
39 views

Bad byte count while using hexdump

I am trying to display a binary file with records consisting of: 8 bytes unsigned int 4 bytes unsigned int 4 bytes unsigned int 4 bytes unsigned int 4 bytes unsigned int I try to display it using ...
0
votes
2answers
24 views

File listing in SFTP doesn't synchronise

I have a SFTP account that I use to store files. It works fine, but when I am using lftp on connection A to look at the files, and connection B to store files, connection A does not reflect any ...
0
votes
2answers
38 views

How should btime be specified?

I have read that Unix systems has not specified btime or generally like POSIX, there is no specification about btime. There is a mention about btime. Therefore the question, how should btime be ...
56
votes
3answers
264k views

Changing a file's “Date Created” and “Last Modified” attributes to another file's

I'm using merge cap to create a merge pcap file from 15 files. For the merged file, I have changed the name to that of the first of the 15 files. But I would also like to change the merged file's ...
1
vote
2answers
46 views

How to create a temporary file that has “normal” permissions?

In a build script I want to create a temporary file that has a unique generated name, then write some data to it, and then rename that file to its final name (the reason for this procedure is that I ...
41
votes
6answers
65k views

How do I shorten the current directory path shown on terminal?

If I am in a deep directory, let's say: ~/Desktop/Dropbox/School/2017/C/A3/ then when I open up terminal, it says bob@bob-ubuntu:~/Desktop/Dropbox/School/2017/C/A3/$ and then I write my command. ...
0
votes
2answers
49 views

Reshaping tab separated file

I have a file that looks like this: Time Flag 0.65 5.885581e-01 0.56 5.847484e-01 0.58 5.278409e-01 0.57 1.140746e+00 1.00 0 0.00 0 1.00 1 0.00 0 But this is because I ...
0
votes
2answers
2k views

find and replace with the value in another file

I have two files with different formats with columns tab spaced. I have to compare the columns column1, column2 of file1 with file2. If they matches, I need to replace the value in column6 of file1 ...
191
votes
8answers
26k views

Why is looping over find's output bad practice?

This question is inspired by Why is using a shell loop to process text considered bad practice ? I see these constructs for file in `find . -type f -name ...`; do smth with ${file}; done and for ...
0
votes
1answer
71 views

How do I copy a file to the clipboard with the terminal?

I'm aware of how to copy the contents of file: xsel -b < myfile.txt But this is not what I want. I would like something like this: ./file2clip.sh myfile.txt Which would copy myfile.txt to the ...
1
vote
2answers
2k views

How to pass arguments to command through Desktop shortcut without having to open a terminal?

I'm using a LXDE desktop. I created a shortcut in the desktop to a python program, which can be passed files to, which are then opened in the GUI. I mean passing files (file absolute paths) to the ...
0
votes
1answer
39 views

Why isn't tail command tracking the changes in a file in realtime? [duplicate]

When I track a file in realtime using descriptor i.e tail --follow=descriptor file_name, it doesn't show the changes made in the file, whereas if i track the file in realtime using name i.e tail --...
0
votes
2answers
62 views

If files are copied from a first volume to a second volume, will the files stay the same?

When I connect the external hard drives to my computer(with FreeBSD or other Unix systems) and copy files from the first external hard drive to the second hard drive, are the files on the second hard ...
1
vote
0answers
38 views

Is there any tool in linux that can monitor two folders in real time?

Is there any tool in linux that can monitor two folders and have the contents of folder a synced to folder b in real time?
0
votes
2answers
35 views

Compare the times of different files using shell script

I have a file with below contents. Here i need to compare the timestamp of HIW.ear in the first line with the timestamp of .jars from the second line and i am running out of ideas on how to do this. ...
0
votes
2answers
40 views

Compare content of two folders/disks (including timestamps,permissions)

I have two directories on two different hard drives and want to check if the content is really exactly the same. From what I read I can use diff -rq dir1 dir2 to check if files are missing or differ. ...
1
vote
2answers
26 views

How do I output the unique lines from a grep pattern match while ignoring other parts of the line?

Suppose I have a file called names.txt, which contains a list of names and corresponding emails of people in the following format: FName1 LName1 <random1@test.com> FName2 LName2 <random2@...
53
votes
4answers
94k views

How to find all binary executables recursively within a directory?

If I use find command like this: find /mydir/mysubdir -executable -type f all executable files are listed (excluding directories), and including executable script file (like script.sh, etc). What I ...
226
votes
19answers
334k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
4
votes
4answers
6k views

How to add an attribute in a tag in XML file by command-line?

I am trying to add field at the end of tag using sed script. Suppose I have a tag in XML file: <book name="Sed tutorial" price="250"/> Now I want to add field as Book_Width="A" after end of &...
6
votes
2answers
4k views

Split a JSON array into multiple files

I have a file that looks like this: [ { "billingAccountNumber": "x", "paymentResponseObject": { "uiErrorDipslayMessage": "", &...
3
votes
1answer
147 views

How to make `du` only include regular files in its output?

I want to list all files in descending order based on disk usage, and have obtained the following commands from this: To list the top 10 largest files from the current directory: du . | sort -nr | ...
4
votes
3answers
117k views

cat /dev/null emptied my log file but size did not change

I'm quite new to Unix. Using Solaris 10 I faced the below issue. There is a large log file with size 9.5G. I tried to empty the file using the below command. # cat /dev/null file_log.txt By doing ...
0
votes
3answers
29 views

Numbering a bunch of files according to the date modified timestamp?

So I downloaded a bunch of documents in chronological order, but I have to copy and edit them, which would change the date modified. I would like to prefix them with a number (001_, 002_...) in the ...
0
votes
0answers
17 views

Graphic file copier with filter

I'm looking for a FOSS graphic file copier that has a filter function, like coping a dir tree removing certain files/dirs. I'm aware of only one actively developed graphic tool for coping files (...
3
votes
1answer
40 views

How to copy a file into another file at a certain position using the command dd?

I want to copy a file of 256 bytes at a certain position into another file of size 2048 bytes containing random data, with the command dd in Linux. The offset I have is 144. I have assumed that bs=1, ...
1
vote
1answer
63 views

Compare first column of a file with value if matched get the record

Can any one help me with the below scenario? I have a reference file has data below: file_id|file_name 1|file1.txt 2|file2.txt 3|file3.txt I have a script which accepts input as file_id and fetches ...
2
votes
2answers
194 views

How is the theoretical maximum file size on filesystems like XFS calculcated?

Documentation for XFS claims its current theoretical maximum file size is 8 exbibytes - 1 byte. However, I am wondering how this calculation was computed? I cannot seem to find discussion of this ...

1
2 3 4 5
90