Logical entities that contain data in a filesystem. Use this tag if your question: is about programs that create files (e.g. gzip, tar, zip); deals with characteristics of files (permissions, size, path/location); or is about management of files (renaming, listing, moving, removing). For operating ...

learn more… | top users | synonyms (1)

-6
votes
1answer
46 views

How to create new script , role like wc [on hold]

I would like to create a new .wc command , but I have no idea how to proceed. Can you help me?
2
votes
0answers
28 views

Undeleteable 33GiB file on a 4GiB USB-Stick. fsck says “clean”, Error: “Operation not permitted”

I successfully installed a live debian 8.x on a 4G thumb-drive, like many times before. However, this time there is a 33GiB tee.1.gz file in /usr/share/man/man1/, which is much larger than a normal ...
1
vote
2answers
24 views

How can I move files from a full partition to one with more room?

How can I move files from a full partition to one with more room? Backstory: Centos7 partitioned the 1TB hard drive on installation. I didn't realize that the partition mysql installs and runs from ...
1
vote
3answers
26 views

Find all files, create CSV with one row per subdirectory and file names in collumns

I have a directory with subdirectories and files structured like this: 01/fileA 01/fileB 01/fileC 02/fileD 02/fileE 03/fileF 03/fileG 03/fileH 04/fileI I'd like to get a CSV that looks like this: ...
0
votes
1answer
12 views

Can I have Linux open a template file when I create a new file with a certain extension? [on hold]

There are files with certain extensions which, when I first create them, I end up putting in a lot of the same stuff as I do other files with the same extension. For a specific example, any .py file ...
2
votes
0answers
19 views

Want to delete a couple of Chinese(?) titled files [duplicate]

After partitioning an external drive, I see two files in a "Rescued Items" directory that have what appear to be Chinese character titles. Many of the characters appear to be dozens of "nul" ...
31
votes
10answers
8k views

What's the fastest way to generate a 1 GB file containing only random numbers?

I tried a bash script, but it took too long to create a simple 1 MB file. I think the answer lies in using /dev/random or /dev/urandom, but other posts here only show how to add all kinds of data to a ...
1
vote
1answer
24 views

How to run the executable file to convert the extension of multiple files in Linux command line? [on hold]

I use (./executablescript filename ) to convert the file format. It works for a single file. But, If I need to do it for multiple files, I get the error message "multiple occurrences". How can I run ...
1
vote
0answers
11 views

Create a file with a streaming interface

I was trying to create a file with a streaming interface just like /dev/random. Basically, I provide some initial contents to the file, and when a program reads from the file, it consumes some bytes, ...
3
votes
1answer
96 views

du command showing different results than st_blocks

I'm implementing du -a in C and I'm using the stat function for this. The problem is that what I get from using st_blocks is 2× what I get when I use the command itself, does this make any sense? or ...
1
vote
1answer
14 views

find matching file and change dirname path

I need to find a very efficient way of moving a file of matching -mtime from one directory tree to another directory, maintaining the same subdirectory path where it doesn't exist yet. eg. move /dirA/...
-2
votes
0answers
20 views

Symbolic link being classified as the type it points to [on hold]

I have the following code to determine wether a pathname is a directory, regular file, etc: if (S_ISDIR(mode)){ mode_s[n] = 'd'; } else if (is_user_exec(mode, ouid, ogid) && (...
0
votes
0answers
12 views

Finding files with invalid owner or group [duplicate]

Background I had installed Exim, Dovecot, and some other software to run a mail server on one of my computers. After configuring everything, I learned that my ISP blocks port 25, so my new mail ...
-1
votes
1answer
37 views

File Stat Program [on hold]

I have a simple program which prints whether a pathname argument is either a directory, regular file with execute privileges, a regular file, a symbolic link, or other. I have the following if ...
0
votes
1answer
27 views

How to edit a file so that it contains a large amount of text? - Linux [on hold]

I have created a file named tomtextfile and I would like to edit it and add in a large amount of text, how is this possible?
0
votes
1answer
39 views

Writing the output of a command to a file in a bash script

I am trying to write a simple bash script that executes the command tcprobe -i $1 where $1 is an mp4 file. Then, I want to write the output of this command, which should be a long string of ...
-1
votes
1answer
24 views

nl - numbering input in descending order

Is this possible to number file lines in descending order? That would be something like: nl -i -1 unfortunately this gives me: nl: invalid line number increment: ‘-1’: Numerical result out of ...
0
votes
1answer
32 views

cat filename | cut -f2 | head -1 > newfile contains more characters than expected

When I run: cat filename | cut -f3 | head -1 I get the following result: apple However when I save this to a file by using: cat filename | cut -f3 | head -1 > newfile I then open this using ...
1
vote
1answer
35 views

Audio files altered by a bash command renaming them

Today I submit a case of an unexpected consequence of a shell command on some audio files that I do not understand at all. Here are the facts: My OS is ArchLinux, the windows manager is Awesome and ...
3
votes
3answers
27 views

overwrite first n lines of a file

I have a 7gb text file I need to edit n first lines of that file (let us assume n=50) I want to do this the following way: head -n 50 myfile >> tmp vim tmp # make necessary edits substitute ...
1
vote
2answers
36 views

How do I grep a directories permissions and see if it lacks write permissions?

I am trying to write a script that runs on boot that checks to see if the boot filesystem is read only, if it is, then run fsck to fix permissions and reboot. Point 1: I am having trouble figuring ...
1
vote
1answer
21 views

Paste text files and add parent directory name as header for each column

In a parent folder I have multiple folders inside it. Within each folder I have text file "text.txt". The text files are similar in all the folders, each text file contain 100 line and one column of ...
-2
votes
1answer
44 views

How can I have a user who can write files but cannot delete them? [closed]

I want to have a user who can write files; but I don't want this user to be able to delete them.
0
votes
3answers
30 views

Search multiple directories and output file names

I have a list of 7 directories. Every day they get a file. I would run one command that would check all the directories at once which provides the output of the file names. Normally I run ls /...
3
votes
3answers
71 views

Append to files

I'm a beginner to linux and I'm trying to solve this problem. I have a directory full of files. My goal is to append text to the beginning of the file. The text that goes at the beginning is the same ...
-1
votes
4answers
44 views

How to pass a file as an argument in linux and get the list of all files in it from file system?

Lets say I have a file by name searchfiles.txt with file names in it: 2345098.txt 2345099.txt 2345100.txt and so on (100 file entries) Now I want to list out or display all the file names that ...
3
votes
2answers
34 views

Secure delete folder CentOS 7

How do I securely delete a folder, with all of its contents, so it cannot be recovered? I have tried the shred command but it only works with files and not folders. I have also found out that there ...
0
votes
2answers
35 views

Removing numerically named files with more than n decimal places

I have data files named by a time step such as: 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 ... 0.99 1 1.01 ... 1000 As you can see, some data file names have two ...
108
votes
6answers
8k 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
33 views

Unzip all files into directories with the same name

Ubuntu 16.04 I have a directory with zip files like this: directory | |---zip1.zip |---zip2.zip | ... |---zip_very_large_number.zip Now, I have another directory /home/usrname/anotherdir. Is there ...
1
vote
0answers
20 views

How to download files from a webpage that points to a directory?

I'm trying to download all the .mp3 files from here; but the download links are not .mp3 . (ex:https://freemusicarchive.org/music/download/98281de10b6cc09df9e99a5a3bd2c7ee0eddaf82) links but a ...
3
votes
4answers
65 views

How to move a file recursively based on size and keep structure

I want to move files bigger than "300Mb" from one directory tree where each file is located in subfolders Example: I have a directory structure: dirA/ dirA/file1 dirA/x/ dirA/x/file2 dirA/y/ dirA/y/...
2
votes
3answers
160 views

How do I sort files into a sub-folder based on filename part?

These are the files in the directory: Ford-Mustang-001.jpg Ford-Mustang-002.jpg Ford-Mustang-003.jpg Chevy-Impala-001.jpg Chevy-Impala-002.jpg Chevy-Impala-003.jpg I would like to sort these into ...
4
votes
1answer
55 views

bitwise-OR 2 binary files

I did 2 rescue attempts on a dying HDD a while back; I ran (GNU) ddrescue first, and then straight dd with manual seeking. I want to get the best of both images. Since any empty stretches in the files ...
1
vote
0answers
18 views

tar files identified by wildcard but discarding file structure [duplicate]

I tar files using tar -czvf pngs.tar.gz folder*/*.png which tars the correct files but maintains the file structure, but I want everything without folders inside the tar-ball. How do I do that? ...
1
vote
2answers
44 views

How is root able to write to the sudoers file with permissions set to 440?

So when I look at the permissions of the /etc/sudoers file, it is like so -r--r----- 1 root root 705 Nov 2 19:57 /etc/sudoers Now, wouldn't this mean it's not writable? So how does the root user ...
2
votes
1answer
39 views

Find files by change date [duplicate]

I'd like to search recursively for files with a specific Change date. Note, this is not the Access or Modify date, but the Change date as outputted by stat. #stat prototype.js File: `prototype.js' ...
0
votes
1answer
17 views

How to recover a file which was overwritten using the “import” command?

I was working on a python script (a webscraper). I wanted to import the script into the python compiler (for no apparent reason). So, I unintentionally ran import filename.py in bash and now my file's ...
2
votes
3answers
65 views

List files in all subdirectories by creation date

I have forgotten the name of a file which is in a directory or one of its subdirectories. I remember the file's extension (.nb) and know approximately when it was created. How can I list all file with ...
0
votes
1answer
22 views

Unable to delete directories copied from elsewhere centos 6 [closed]

One of our users mistakenly copied some system directories (e.g., /lib) to her home directory, using command cp -r /lib ., and then she cannot delete these directories. Command rm -rf ./lib returns a ...
-1
votes
3answers
73 views

How can I explore linux shell on a browser? [closed]

How do you open a Linux shell on a browser in order to explore it? Similar to how you can explore windows files with the "file://" path. Basically I'm trying to find a way to browse through ...
3
votes
2answers
50 views

List file + directory path recursively sorted by access time

I'm doing a LRU script, but after 20 hours working on it (I'm newbie), I have a problem with recursive mode that I can't fix. I just need a command that show me files sorted by access time (--time=...
3
votes
0answers
18 views

File names contained in particular block group blocks

How do I see/list what files have blocks in a particular block group? I'm looking at a small disk image with ext3 file system. Can I use debugfs, and if so, how?
1
vote
1answer
95 views

cat: write error: Invalid argument

Writing to a custom character device using cat 123 > /dev/chardev gives cat: write error: Invalid argument I have changed the permissions to 666 and even tried it with sudo. Still the same ...
0
votes
1answer
34 views

Renaming files with numbers to corresponding 1-n numbers in order [duplicate]

So I have a bunch of files in a folder, where a leading number represent the order of the file, but they are not the usual 1-n, like this: 2-file.txt 4-file.txt 7-file.txt 12-file.txt and I want to ...
1
vote
1answer
40 views

Is it possible to make files executable by owner by default?

Since the file base permissions for umask are 666, is it possible to make a file have 750 permissions when created?
0
votes
0answers
30 views

What's the point of self user permissions on a file? [duplicate]

Every file has three groups of permissions: user, group, and other. I get why group and other would be needed, but I can't see a reason for the user permissions. why would a user that created the file ...
4
votes
3answers
80 views

Get list of files group by Date

I have a directory with files coming for every day. Now I want to zip those files group by dates. Is there anyway to group/list the files which landed in same date. Suppose there are below files in a ...
1
vote
1answer
63 views

How does Linux calculate the total block count when running /bin/ls -l?

I am trying to figure out how the program /bin/ls -l calculates the total size (block count) for a directory. By this I mean the output total number that it prints right before the directory contents. ...
56
votes
3answers
7k views

I've just “mv”ed a 49GB directory to a bad file path, is it possible to restore the original state of the files?

I have (well, I had) a directory: /media/admin/my_data It was approximately 49GB in size and had tens of thousands of files in it. The directory is the mount point of an active LUKS partition. I ...