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)

-1
votes
1answer
9 views

Move all sub-directory content up one level

My top level directory contains a bunch of sub-directories: af ar ca cs da de el en ... (lots more) Each of these directories has the exact, same structure. They contain two directories: v2.3.0 ...
1
vote
4answers
72 views

Bash script to fix file names

I have hundreds of folders with thousands subdirectories and files inside of them. The file names are currently in the format sf{number}-{number} - {text} and I need everything deleted until ...
1
vote
1answer
18 views

Delete old package versions within a backup folder

I have a folder that contains a large number of tar.xz packages that have their version number in their filenames . ex : vlc-2.2.2-3-x86_64.pkg.tar.xz (old and should be deleted) ...
18
votes
4answers
2k views

Can a file that was originally sparse and expanded be made re-sparse

I know that copying or transferring what was originally a sparse file without using a utility that understands sparse files will cause the 'holes' to be filled out. Is there a method or utility to ...
68
votes
6answers
170k views

How can I count the number of lines of a file with common tools?

I am redirecting grep results to a file, and then using cat to show its contents on the screen. I want to know how many lines of results I have in my results file and then add it to some counter. ...
1
vote
1answer
21 views

Compressing a folder but do not compress specific file types but include them in the gz file

I am using tar with pigz to compress a folder and save a backup. Size of this folder ~250 GB or more. This folder has variety of content including numerous text and log files, ISOs and zip files in ...
1
vote
0answers
24 views

rhel - file modification logs

I found a strange file in my /home/user named FireZeMissiles1111.tmp. I am the sole user and did not create it, so it is kind of suspicious. It may have been left there by a program who's programmer ...
0
votes
2answers
67 views

search for files with specific text and copy these files to another directory

Relatively new to unix and still learning -- How do I search for files in a directory that contain a specific text and copy them to another directory ? I am using .ksh shell.
0
votes
1answer
49 views

Validate user response in shell script

My shell script is working fine and the files are copying to the remote directory. However I need to check if my INPUT_STRING is starting with S and also check if the files are present in the ...
1
vote
1answer
39 views

Why are given file sizes slightly different between Windows and Linux?

I have just transferred (via scp) a bunch of .gz files from a Windows machine to my Linux machine. They are large files so I checked they had transferred entirely by comparing file sizes. Those that I ...
7
votes
6answers
680 views

Number of files not containing given string

I read the question about how to find out the number of files that contain a certain string. This is possible with grep -l "string" * | wc -l. Is it possible to invert this, finding the number of ...
2
votes
4answers
96 views

Copy files to new directory only if name of file is in an array

I'm not much of a zsh buff but I imagine this should be an easy layup for someone: I can bulk copy files from sourcedir to targetdir with the following: $ find sourcedir -type f -exec cp {} ...
4
votes
4answers
217 views

Prefer file types in command line

Often I have to annotate multiple pdf documents using xournal. If I start with a directory of "fresh" pdf files, I just open them all with xournal: for f in *pdf; do xournal $f&; done When I ...
0
votes
0answers
20 views

Assign a name to an inode [duplicate]

As far as I can tell (from what lsof tells me), once a file is opened by a process, I can rm it and the process will still be able to access it, because at that point all that counts is the inode. ...
20
votes
8answers
39k 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 ...
1
vote
1answer
54 views

copy huge number of files into date structured directory order

I need to copy around 40.0000 files into date structured folders. example file: /var/public/voicelogging/quality_monitoring/20151209/bbbbbb_I_20151209-185841_xxxxxx_12434_89343.WAV Is one of the ...
2
votes
3answers
157 views

reformat a text file to have all text on one line using CentOS 5.6

I have a 210-line block of HTML that I have stored in a HTML for debugging purposes. The HTML, as you would expect, is formatted accordingly so is stored in the file with spaces and tabs. Is it ...
5
votes
1answer
467 views

Using syncing files only comparing file name and not extension

I'm trying to sync 2 folders containing audio files of multiple types (WMA, MP3, M4V,...). I want to sync these folders but the sync process should only take into account the file names, not the ...
17
votes
3answers
34k views

How do I use wget with a list of URLs and their corresponding output files?

Suppose list_of_urls looks like this: http://www.url1.com/some.txt http://www.url2.com/video.mp4 I know how to use that with: wget -i list_of_urls But, what if my list_of_urls has this, and they ...
11
votes
2answers
571 views

dd: write to multiple disks?

I have 2 exactly same formatted, same size and same brand SD-cards. I would like to dd image to /dev/disk2 and to /dev/disk3 at the same time. Pseudocode sudo dd bs=1m ...
2
votes
1answer
27 views

Find differences of ownerships between two home folders?

I have two home folders: /home/masi and /home/masi_backup and I would like to find the differences between files of the two directories. Pseudocode vimdiff <`ls -la /home/masi` <`ls -la ...
3
votes
3answers
1k views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
0
votes
1answer
24 views

Copy and rename on collision

I'd like to merge the content of these folders with a command line. . ├── folder1 │ │ file.txt │ ├── folder2 │ │ file.txt │ └───folder3 │ file.txt How can I do this ?
0
votes
1answer
59 views

inserting modified date into filename - 2 cases

I believe I'll ask two separate questions, but the context is the same, so I hope it's alright. I have an output of few processes as presented below (which I can't modify). 25978.csv 26044.csv ...
1
vote
4answers
54 views

How to gather the name of the files in each subdirectory into a text file in that subdirectory?

I wanted to save the names of all files in each sub directory into a text file in that sub directory, so I wrote this script: #!/bin/bash for X in "$PWD" * do if [ -d "$X" ]; then ...
1
vote
3answers
94 views

How can I compare different files without opening them?

I have two directories A and B; each one contains a lot of sub-directories geom001, geom002 ....etc each sub-directory contains a file named results. I want to compare, without opening any of ...
4
votes
7answers
716 views

How to split a filename list in 5GB sets?

I have a pretty big list of files which I like to group in smaller list of 5GB each for further processing. The file list is in the following form: "size" (from du) "tab" "absolute path", like this ...
0
votes
0answers
17 views

burn ISO + save other files

is it possible to burn a linux installer on a flash drive with rufus on my 8gb flash and then after the ISO finished burning, just copy paste in 1 folder some other files. And then the istallation ...
0
votes
0answers
37 views

hidden directories to ls (not dot prefixed file)

I'm facing with a uncommon issue, which is: After btrfs read failure and a btrfs check --repair on my partition mounted in /home, it seems that some directories have disappeared. I explain : When I ...
3
votes
1answer
27 views

What are semi-files?

I'm reading a paper about Android/Linux. It contains a line I'm not able to understand. I tried searching about "semi-files" but nothing relative came up. Can someone please rephrase it or explain it ...
2
votes
3answers
809 views

Rename files with random characters from sha1sum. Will the names be unique?

I'm using this command to rename files with random characters from sha1sum and move all files from subdirectories to the current directory: for fname in `find . -type f`; do mv "$fname" $(echo ...
0
votes
1answer
23 views

Retrieve text from a large file using a smaller matching header

I need to extract the text between two headers, if the first one matches with a source file for lookup the headers to search, example: &Header1 ...
3
votes
3answers
64 views

How can you move or copy specific files from a list of text files

So I have a directory of like 200 of the the following types of files: gre_6_c1_d34567.h3 gre_6_c1_d95543.h3 gre_6_c1_d42354.h3 gre_6_c1_d01452.h3 gre_6_c1_d23168.h3 gre_6_c1_435435.h3 The only ...
3
votes
4answers
413 views

Bash script detecting change in files from a directory

I am a beginner in bash scripting and I am trying to make a script that detects if any of the files in a directory were changed within a 2 seconds interval. What I have so far is: #!/bin/bash for ...
0
votes
1answer
23 views

How to manipulate a file descriptor in another process? [duplicate]

Is there any way to manipulate (read, write, etc..) a file descriptor for any app which can be found in the path /proc/{pid}/fd? Especially for sockets. $ ll /proc/4229/fd total 0 lrwx------. 1 ...
1
vote
4answers
38 views

rename the 10 most-recently modified files on AIX

I have some .xls files in a defined directory (say in /A/B). I want to rename top 10 latest files and append "-bkp" in their names. I tried, not working ls -lt *.xls | head -1 | awk '{print "mv " $9 ...
1
vote
2answers
2k views

What is the cause of this error: Error: EACCES, permission denied

I have two three users: db, nr, ba All three are members of the group dbp Node.js is installed in /usr/bin If I run the command : /usr/bin/node /home/db/dbb/m/i.js Then it works fine when I run ...
1
vote
3answers
2k views

Read line from file then delete

How can I read a series of lines from a file and then remove each line? Obviously I can read like this: while read -r line; do echo $line done < myfile.txt But if I do this: while read -r ...
1
vote
2answers
59 views

Process several files and print filename without extension and the value of a specific key

I have ASCII file and I want to output the file name and a specific field from this file beside each other. For example: The contents of the ASCII file "data1.txt" is as follow: Name: John Age: 90 ...
15
votes
3answers
11k views

Finding all “Non-Binary” files

Is it possible to use the find command to find all the "non-binary" files in a directory? Here's the problem I'm trying to solve. I've received an archive of files from a windows user. This archive ...
6
votes
4answers
22k views

'chmod g+s' command

Hello I want to understand the role of the chmod g+s command in Unix. I also would like to know what it does in this particular context: cd /home/canard; touch un; chgrp canard .; chmod g+s .; touch ...
0
votes
0answers
43 views

What is a “file header” in Linux file systems?

The following sentence appears in an article in the web: All cryptographic metadata is stored in the headers of files, so encrypted data can be easily moved, stored for backup and recovered. ...
3
votes
2answers
64 views

find latest file created in folder and grep contents

I have a need to search a certain folder for the newest created file and grep the contents for a pattern. I have had ok success so far using this command: find /var/log/folder -type f -printf '%T+ ...
1
vote
1answer
36 views

Find All images file size and width in directory

I'm trying to find all .png .jpg and .gif files in my directory. I'm getting the file sizes properly but unable to get image width (I'm using imagemagick) in log file. Script code #!/bin/bash for d ...
-8
votes
1answer
26 views

What does it mean when Linux states “the directory does not contain all necessary files”? [closed]

Copy all the files from the directory /usr/local/linuxgym-data/gutenberg whose names contain the string s2 into your ch4-pipewild/s2 directory. mkdir s2 cp *s2* /usr/local/linuxgym-data/gutenberg I ...
-3
votes
1answer
40 views

How can I treat my disk like one big file?

I was reading about device files in FreeBSD, but my understanding is not great. To practice, I thought up the following scenario. I suspect that the problem can be solved using device files. Imagine ...
0
votes
3answers
840 views

Creating a character device file

How to create the character device files? I have tried cat > xxx^c But I can't create a character device file
80
votes
17answers
25k views

Is there an easy way to replace duplicate files with hardlinks?

I'm looking for an easy way (a command or series of commands, probably involving find) to find duplicate files in two directories, and replace the files in one directory with hardlinks of the files in ...
70
votes
1answer
7k views

Why does the following script delete itself?

If you create an executable file with the following contents, and run it, it will delete itself. How does this work? #!/bin/rm
1
vote
1answer
43 views

Pass a list of URLs contained in a file to curl

I have to set ACL on a multiple files. I have downloaded a list of object stored using below commands. C:\Users\Gshrivastava\Downloads\curl_748_0>curl -o urlname.csv -i -k -H "Authorization: ...