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

learn more… | top users | synonyms (1)

0
votes
2answers
15 views

Extra space with counted line number?

I count the number of lines of my file with this command on OSX: nl=$(wc -l < ~/myfile.txt) Say, nl turns out to be 100. Now, I wish to use the result nl in another command, but weirdly, echo ...
1
vote
2answers
69 views

Find largest files of a particular owner

I accidentally chown'd my entire file system to a particular user, after correcting the issue I've found disk space still being consumed by that particular user's files even though their account ...
-11
votes
0answers
44 views

unix standard file streams [duplicate]

Each Unix process has three standard file streams associated with it. Give two of these streams and give a command line example of each being re-directed
3
votes
3answers
58 views

How to change suffix of the files

In a directory structure which has multiple subfolders and files in it. Some of the file names have the suffix _create (e.g. java1_create) and some of them with _bak (java2_bak). I need to rename ...
4
votes
4answers
231 views

grep command not working in conditional statement

I've a bash script that's supposed to go over all the filenames and print them only those that contain a certain letter (let's say it's 'o'). What I've done: command=`ls -l` for file in $command do ...
4
votes
4answers
135 views

Move files by date into different directory using CLI

I have a large number of pictures from an old hard drive that I'm trying to organize. If I run ls -l, I notice all of these files have a creation date of 2012 or before. Ideally, I'd like to move ...
1
vote
1answer
48 views

Comparing a bunch of files on different folders

I have two folders with 200 txt files each, all files named like file1.txt, file2.txt, file3.txt, etc., on both folders. Is there a way to use one command to compare file1 in both folders, file2 in ...
0
votes
1answer
19 views

Returning last-written file, containing particular sub-string in file name?

Whilst monitoring logging I have to go to my log files, order by written date, so I can then see the name of the log file for the most-recent execution of my application. Is there any way, given a ...
2
votes
2answers
59 views

How do I check which files are written by an application?

On my system, sar reports an average write to disk about 5MB/s. Using dstat I found that it's not so permanently, but there are peaks to 30-50MB/s, and then are sleeps. Using iotop i found that most ...
-1
votes
2answers
48 views

Error in file comparison - awk [duplicate]

I have two files file1.txt, file2.txt. I want to select records which are common to both file1.txt and file2.txtbased on column 2 and column 3 and copy them to out.txt with additional column(column 4 ...
1
vote
1answer
18 views

Generating a long sound file with SOX without actually playing the tone

I know how to play a tone for a specific amount of time using SOX. play -n synth 5 sin 347 I know how to save a tone using SOX. sox -n note.mp3 synth 5 sin 347 Question is : How can I save a ...
4
votes
4answers
103 views

Stable sort a file by presence of ordered substrings on each line

I have a list of sound sources that I'm processing with a script. An example would be: alsa_input.usb-AVEO_Technology_Corp._USB2.0_Camera-02-Camera.analog-mono ...
0
votes
2answers
41 views

Change the owner of a file I can write to

I have a folder called fruit with permission 777 and its owner is fruit. I want to create a folder named apple under the fruit folder. But I want to set this folder's owner as apple, not fruit. ...
1
vote
0answers
30 views

Why use mmap over fread? [migrated]

Why use mmap as opposed to reading from a filestream in chunks into a byte array? I guess I just never thought about using mmap before. mmap(2) fread(3) // Open the file // Read from the file ...
0
votes
2answers
33 views

Generate a list of installed PHP extensions

My goal is to write an as simple as possible (but not more simple) that generates a list of currently installed PHP extensions (*.so files) that the user can simply copy/paste into their php.ini. It ...
1
vote
1answer
44 views

sort file based one colum and group by another column

I have a file of three columns: 1 A 0.5 2 B 0.7 3 A 10 4 C 4 5 B 4 I want to sort the file by increasing order of column 3 and group by column 2 1 A 0.5 3 A 10 ...
1
vote
2answers
51 views

Compare three files: lines present in one, but not in the other using column comparison

I have three files file1.txt, file2.txt, file3.txt and they are of same format(same number of columns with same data type). I want to select records from file1.txt which are not present in file2.txt, ...
0
votes
1answer
28 views

Delete excel files which are older then 1 month

I need to delete excel files which are older then 1 month. need to set cronjob. any suggestion for this? which script can be used to search excel files from particular directory and delete them.
2
votes
1answer
37 views

How to compare two directories thoroughly without git?

Here thoroughly means “list all differ files, find those files with same name and different content, list the difference of content”. Before I got a lazy solution, git init one directory and copy ...
-1
votes
0answers
11 views

Where to find rescan-scsi-bus.sh in linux os

I can't find the rescan-scsi-bus.sh. I installed yum install sg3_utils. Where to find this file? I checked in /usr/bin/rescan-scsi-bus.sh but i didn't found it.
6
votes
5answers
196 views

How to execute a bash command in all possible subdirectories?

Let's say my main directory is /home/test Under it i have lots of subdirectories and under subdirectories still a lots of them and so on. Example: /home/test /home/test/subdir1 ...
5
votes
2answers
147 views

How to sync two folders with command line tools?

Having migrated to Linux from Windows, I would like to find an alternative software to Winmerge or rather learn command line tools to compare and sync two folders on Linux. I would be grateful if you ...
1
vote
1answer
28 views

Assigning ls output to a variable gives unexpected behavior

I was writing a script to clean a text file from a directory (I know,it's a bad idea but I really need it) and I wrote this: #!/bin/bash var=$(ls -p /direcotry/to/file | grep -v /) truncate -s 0 $var ...
2
votes
2answers
49 views

How can I start a file-processing daemon? [closed]

How can I run a script-based tool which will process files continuously downloaded to given directory as they arrive? I'd like to minimize delay (~1 second is OK), script can have own infinite loop. ...
18
votes
5answers
540 views

Find files that a user can write, efficiently with minimal process creation

I am root. I would like to know whether a non-root user has write access to some files - thousands of them. How to do it efficiently while avoiding process creation?
0
votes
1answer
21 views

UMASK not having effect on some file creations

I have umask set to 002 in my Linux server and its working fine while I create file using touch. But I still have some files that are created with permission contrary to umask. These problematic files ...
3
votes
2answers
43 views

Is it possible to have a lag between scp and checking for new file

Got a cronjob that downloads things regularly: if ! su scpuser -c "scp ..." > /dev/null 2>&1 || ! [ -f $scptarget ]; then; error "did not download stuff" $scptarget is where the thing ...
2
votes
2answers
374 views

Why does touch create new files?

I understand that this might be a very strange question to ask, but I couldn't help my curiosity, and I couldn't find this anywhere on the net (And I'm too lazy/incompetent to look up the source ...
4
votes
0answers
85 views

Unexplained files found in home folder

For background information, I'm running openSUSE 13.2 and KDE 5. Today I found a number of unexplained files and folders in my home folder which state they've been edited 3 days ago. I do not ...
0
votes
2answers
54 views

Files greater than 1 GB and older than 6 months

I want to find files which are greater than 1 GB and older than 6 months in entire server. How to write a command for this?
2
votes
1answer
18 views

Seeing all regex matches in a file in Bash

I'm in bash and I have a file, I want to find all matches of a regex in it and have them printed. How do I do that? Followup: Assume I want to print only unique matches, i.e. if a match appears ...
0
votes
0answers
15 views

Any GNU C examples where faccessat() function (or equivalent) is used? [migrated]

In reading IEEE Std 1003.1 (POSIX Base Spec) regarding access(), I came across this note: "The purpose of the faccessat( ) function is to enable the checking of the accessibility of files in ...
31
votes
4answers
1k views

Does bash open files in O_APPEND when using “>>” on linux?

If we use echo 1234 >> some-file then Documentation says that the output is appended. My guess is that, if some-file does not exist, then O_CREAT will make a new file. If > was used, then ...
-2
votes
0answers
9 views

File manager in BlackArch [duplicate]

What file managers available for BlackArch? Are available some managers In default distro of BlackArch? If there are F.M. - where is it?
6
votes
3answers
149 views

How to copy a directory recursively using hardlinks for each file

I want to create a "copy" of a directory tree where each file is a hardlink to the original file Example: I have a directory structure: dirA/ dirA/file1 dirA/x/ dirA/x/file2 dirA/y/ dirA/y/file3 ...
1
vote
3answers
51 views

Is it possible to create dynamic content on file read operation?

Is it possible to generate file content based on file name? I need a lot of similar .conf files with content depending on file name only. Can I create some "dynamic" file and generate a bunch of ...
4
votes
3answers
92 views

Why can't I read /dev/stdout with a text editor?

I just started learning how Everything Is A FileTM on Linux, which made me wonder what would happen if I literally read from /dev/stdout: $ cat /dev/stdout ^C $ tail /dev/stdout ^C (The ^C is me ...
1
vote
3answers
30 views

How to change the permission and group-owner of a file at the same time

For changing file permission, I know I could use chmod. For changing group-owner, I could use chgrp. However, if I want to change both permission and owner at the same time, any command I could use on ...
8
votes
2answers
401 views

Create a gzip file of a predetermined size

I want to test an upload of files of content type application/x-gzip of various sizes ranging from 100 MB to 999 MB. How can go I about creating .gz files of these predetermined sizes? If I do dd ...
4
votes
2answers
86 views

Are files defined by their content blocks, inodes, both, or filenames?

Are files defined by their content blocks, inodes, both, or filenames, or something else? Fundamentially, what is the definition of a file? E.g. two hard links can share the same inode and thus ...
2
votes
1answer
34 views

Clustering identical files ignoring spaces & linebreaks

Consider a folder with many XML files (10K small text files). Some XML files are identical, some are different. I would like to find out what files are identical (ignoring whitespaces, tabs and ...
2
votes
2answers
44 views

Efficient search of unique owners of files and directories

I would like to view the unique owners of all the files and directories underneath a certain directory. I have tried: ls -ltR <dir-path> | grep -P '^[d|\-]' | awk '{print $3}' | sort | uniq ...
2
votes
2answers
35 views

Relation between timestamps of files

If I am correct: atime is the last time the file was read/accessed. mtime is the time when the file content last modified. ctime is the time when the inode of the file, was last changed. ...
-2
votes
0answers
48 views

creating new filesystem?

Is it possible to create directory/filesystem that would be beyond unix-like filesystem ( I mean "/" ) so when I will use command pwd , its output would be "example_folder" not "/example_folder" . I ...
2
votes
3answers
67 views

Search and Delete duplicate files with different names

I have a large music collection stored on my hard drive; and browsing through it, I found that I have a lot of duplicate files in some album directories. Usually the duplicates exist alongside the ...
2
votes
2answers
52 views

Find files created by a particular user

How would I go about discovering all of the files created by a particular user and display them to the screen? I've started a script that prompts the current user to enter the username of whom they ...
-1
votes
1answer
26 views

Advice with How to Return the # of Files found within a folder [duplicate]

Create a script to ask a user for the name of a folder and have the script return the number of files found within the folder. If folder doesn't exist, display error message to the screen I've gotten ...
0
votes
1answer
189 views

How can I delete files on a read-only file system?

I have an encrypted .dmg file with some useless files that I need to delete to make space. How can I delete them without having to convert them into a read write system and then back? (Would take 4~5 ...
1
vote
2answers
35 views

Read the file from one Unix server to the other Unix server

I have a Pro*C program which I run on Unix server a but the input file required for this program is on other Unix server b. Whenever I run I have to copy the file from server b to a. Is there any way ...
0
votes
2answers
29 views

Precaching the list of files of the filesystem

I was wondering where and in what form a list of files and directories is stored on the ext4 filesystem. The problem is that whenever I try to access a certain directory for the first time since boot ...