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

learn more… | top users | synonyms (1)

6
votes
6answers
652 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 ...
0
votes
1answer
28 views

move files with special characters to new directory

I'm trying to write a loop for a script that checks a specific directory for any special characters and moves those files to a specific directory (except spaces and hyphens - those are simply replaced ...
67
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
0
votes
0answers
6 views

Track amount of data application and a device file are exchanging

Is it possible to track how much data is going into a device file and an application as a third person? Background A web server is communicating with a device /dev/ttyACM0. The server offers a HTTP ...
1
vote
1answer
29 views

Limited access to a directory's contents

There is a file in a directory that me and the other users want to be able to read. I want the other users not to be able to see the other files in the directory. They should be able to read a ...
-1
votes
1answer
32 views

File size limits

i have a text file which its size is 23.5 Mb. i want to reduce file size under 20 Mb. how can i do that? the file type is: plain text document (text/plain). this file have ~40000 line and ~500 column. ...
3
votes
2answers
502 views

Redirecting/grep'ing an existing shell's STDOUT

I run a lot of long running processes (simulations) that print progress to STDOUT. I occasionally forget to redirect to STDOUT to a file I can grep, and it's usually too far along to restart. ...
1
vote
1answer
22 views

Ubuntu shell curly brace expansion - confusion with sox command

I'd like to search through multiple subdirectories and convert all .mp3 files to .al files. Here's how I do it: find . -name '*.mp3' -type f -print0 | xargs -0 -t -r -I {} sox {} -r 8000 -c1 -e a-law ...
3
votes
2answers
259 views

How can I find files with a long first line?

currently I have a problem with a server. One user who is hosting a lot of sites got hacked and some of his php files were modified. Now I want to get a list of the infected files and also want to ...
0
votes
1answer
35 views

How to maintain only four lines in my file in shell scripting?

Input file: 01.05.2016 87893938 02.05.2016 35435345 03.05.2016 35435345 04.05.2016 12345678 I want to keep only four lines in my file. that means if date 05.05.2016 6905698 is inserted then ...
2
votes
1answer
65 views

Cannot mv to a subdirectory of itself

I am running this simple script and I am trying to create a cron job so that the file gets copied to my thumbdrive (with the new name) sudo cp /home/pi/NewLog.log /media/usb sleep 20 cd ...
1
vote
2answers
42 views

Check in pure bash that the download is complete

short story is, I probably need a simple loop in bash which checks periodically whether the size of a given file has changed or not since last checked. Long story, I will be downloading a file ...
2
votes
5answers
378 views

How to find what device a file is on (and use that in a script)?

I want to find out what device my file is on so that I can use it in a script. I can get this far: $ df . Filesystem 512-blocks Used Available Capacity Mounted on /dev/disk0s2 498438976 ...
1
vote
2answers
897 views

How to give sftp access to sub-directory only not to parent

I want to give SFTP access to user tom for directory /var/www/html/my_project/. while I don't want to give any SFTP access to directory /var/www/html/. currently /var/www/html/my_project/ and ...
0
votes
0answers
8 views

When creating a copy of files for a development server, how should I handly differring Group and Owner IDs to allow for easy syncronizing? [on hold]

I am doing web development for a client, and have created a copy of all their files in a development area. This is a separate cpanel account, and I have copied the files across and maintained the same ...
2
votes
1answer
62 views

How to delete files with ~?

I have removed all my python code from the home directory, but when I do ls I get: a11.py~ class1.pdf foobar.txt~ n1 pic.py~ When I do ls like this: ls *.py I get: ls: cannot access *.py: No ...
0
votes
0answers
14 views

Can't delete files using SSHFS on windows

My problem is that i can't delete any fails from any folder using my windows sshfs client. Even though i'm logging in through root account, it still says that i do not have enough permission to ...
78
votes
17answers
24k 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 ...
3
votes
3answers
75 views

Display files to size with lower and upper bound without using `find`

I need to create a program via vim in Linux called between. The script takes two arguments as the lower bound and upper bound of the file size, and prints out a list of file names as well as their ...
13
votes
4answers
601 views

dd: multiple input files

I need to concatenate chunks from two files: if I needed concatenate whole files, I could simply do cat file1 file2 > output But I need to skip first 1MB from the first file, and I only want ...
11
votes
5answers
9k views

How do you compare two folders and copy the difference to a third folder?

You've got three folders: folder current, which contains your current files folder old, which contains an older version of the same files folder difference, which is just an empty folder How do ...
0
votes
2answers
16 views

How can I give files extended attributes in mac os x?

How can I give files extended attributes in mac os x? Mac os x doesn't have the 'setattr' command.
0
votes
0answers
11 views

Qubes/Xen OS: access file manager for dom0

I hope somebody more experienced with Qubes specific terminal commands can help. If the KDE manager is installed, how does one open via terminal input the file manager for 'dom0'? To browse 'Home' ...
2
votes
2answers
859 views

how to find out the full path of the command from the result of lsof -i

lsof is a great utility, just now started using it. lsof -i | grep smtp => this give the following result. httpd.pl 212548 global 3u IPv4 893092369 0t0 TCP ...
1
vote
1answer
787 views

Apache created files and its permissions for CentOS 6.x

In short, I have an authenticated HTTP-POST that: posts a jpg image (created as 666 apache:www) into /directory1 (777 ftpuser:www) creates /directory2 (created as 666 apache:www) in a 777 ...
2
votes
3answers
37 views

Is there a way to see the dimensions of a jpeg file in linux using the command line?

I have some .jpeg images saved in a file in a cluster at school. I am at home using PuTTY to access one of the Debian nodes. I'm able to get to the folder with all the images but I need to see the ...
0
votes
0answers
21 views

Where is my 7za data being written to

I have a weird question about 7za on Centos 7. I am adding a file to a 7za archive using the following command (the total size of the directory is around 40GB) /usr/bin/7za a -ppassword -t7z -mmt=off ...
0
votes
0answers
17 views

Problem in writing to a File after Power on/off? [closed]

I am writing the content of my script to a .log file using > operator. I am doing it on a Raspberry Pi. After a Power on/off if I try to execute the script it doesn't write to the file. I then ...
1
vote
2answers
33 views

Are all files outside of /home/userabc owned by root?

I'm writing a tar implementation for a package manager, and I wonder if I can skip the permission setting of the user in the tar headers and keep what is there by default, the user who wrote the ...
0
votes
2answers
38 views

How to see information inside inode data structure

I can do an ls -li to see a file's inode number, but how can I list information inside a particular inode by using that inode number.
0
votes
3answers
22 views

How to apply dos2unix recursively to all the contents of a folder?

Is there a way to apply the dos2unix command so that it runs against all of the files in a folder and it's subfolders? man dos2unix doesn't show any -r or similar options that would make this ...
54
votes
5answers
31k views

Find duplicate files

Is it possible to find duplicate files on my disk which are bit to bit identical but have different file-names?
3
votes
2answers
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
0answers
12 views

Import Windows file into Linux Ubuntu VM [duplicate]

I have a Ubuntu/Gnome VM using Virtual box installed on an external usb drive. I have been emailed a ubuntu script recorded session from another user to my Windows PC. I want to be able to import ...
0
votes
1answer
254 views

Ambigous redirect done >$2

I have finished my bash script but I am still getting two errors. I've also searched for related issues but none worked: #!/bin/bash avem_element () { local e for e in "${@:2}"; do [[ "$e" == ...
0
votes
1answer
115 views

How to fix ntfs file problem when there is now windows?

I have a "stubborn" file on an NTFS partition which refuses to be deleted. A little background on the problem... Problem happened when I was running Zim on my Linux and the system froze due to some ...
0
votes
0answers
98 views

Google Drive HTTP Error when downloading .zip file with Firefox

I'm using openSUSE 42.1 and opened a fresh install of Firefox, but somehow when I try to download a zip file from my Google Drive, an error is shown: Could not download "[filename]". HTTP error. ...
0
votes
1answer
39 views

How “Max open files” soft and hard limit are set for specific process?

I used the cat /proc/<pid>/limits command to check the Max open file hard and soft limit, but I want to know how this value will be set and can it be increased or decreased? Is this value is ...
7
votes
2answers
629 views

Zip Archive With Limited Number of Files

What command can I use to create zips with a file number limit? I have a folder (no subfolders) of, say, 5000 files, so I would want a command that could divide that number and create 10 individual ...
-1
votes
1answer
20 views

adding date to beginning of file name using script

I have multiple files that need to be renamed with a date added to the beginning of the file name that I am trying to script. I'm using the cp command because I need to keep the original file I need ...
1
vote
2answers
46 views

Why does SCP fail when “RequestTTY force” option is enabled?

In my SSH config file, I have to enable the RequestTTY force for some important reasons. And currently my config file looks like this: Host x.x.x.x HostName yyyy StrictHostKeyChecking no ...
6
votes
2answers
10k views

What is nobody user and group?

On my server (Synology DS212) some files and folders have nobody nobody users and groups. What are the characteristics of this user and group? Who can write of read this file? How can I change it ? ...
5
votes
1answer
20 views

Clear recent open file history on Linux Mint

Sometimes others in my household briefly use my computer, when they do I sometimes don't want them to see my file history. I know how to prevent Bash from writing entries to the ~/.bash_history file ...
5
votes
4answers
7k views

Constantly check if file is modified bash

I have a file called file1 I want in a script, whenever there is a change in it, do something, a beep sound actually. How do I do that ¿? Thank you in advance
1
vote
0answers
51 views

how to limit file manager access based on users on Ajenti

I installed Ajenti-v on my ubuntu server 15.10 and I want to create multiple users with specific access to their home directory. currently, whenever I create a new ajenti user (which is synced with ...
73
votes
2answers
112k views

Empty the contents of a file

I am aware of three methods to delete all entries from a file. They are >filename touch filename filename < /dev/null Of these three I abuse >filename the most as that requires the ...
4
votes
1answer
44 views

File permissions on Linux?

I am surprised that /mnt, /media or even /opt are not writable by myself on my own system (Linux-Ubuntu). Should I always use sudo for any action on these paths? Or would it be better to add myself ...
1
vote
2answers
37 views

How to apply an awk script to multiple files in one folder using a loop

I am trying to apply one awk script to all the files in one folder, I am using: for %%i in (*.txt) do (awk -f NormalizeFiles.awk "%%i" > new\"%%i") but then I get the message: Syntactic error ...
3
votes
3answers
94 views

How can I test if a file in /root exists without su to root?

My OS is Ubuntu 14.04 LTS. I got a file /root/1.txt, and logged in with 'yu', who doesn't have read permission on this file. When I use the code if [ -e /root/1.txt ] , it returns false. I know I can ...
3
votes
2answers
65 views

Changing a file's modified date based on date in file name

I have a directory full of photos with file names in this format: IMG-20160305-WA0001.jpg. The date taken is obviously in the file title. Unfortunately the date modified on all files is today. I ...