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

learn more… | top users | synonyms (1)

0
votes
1answer
9 views

Can I use lzma compression, without using “tar”, on OSX 10.10.3?

I kind of think of OSX as Unix by another name. But, if I need to move this to the Apple forum, please tell me! I can create tar files compressed using lzma as such: $ ls ./DbDumps alpha.dmp ...
0
votes
1answer
24 views

Copying directories to directories with different names

How can I copy a number of directories: directory_01 directory_02 directory_03 to different directories tmp_directory_01 tmp_directory_02 tmp_directory_03 where each tmp_directory_* directory ...
0
votes
2answers
30 views

Why is there a minor number in /dev for directories such as pts?

This is a part of /dev in CentOS 6.6. What is the meaning of the minor number for directories like ., .. , bsg, block and ... ? drwxr-xr-x. 18 root root 3800 Jul 3 06:00 . dr-xr-xr-x. 21 ...
1
vote
1answer
33 views

Delete the first n bytes of a file in O(n) time

I've been browsing around looking for a solution for a personal project (Read: a coding experiment), but nothing quite seems to fit. To be honest, I don't even know if it's possible. Now, there's ...
1
vote
1answer
36 views

What is going on with Google Chrome and deleted files

Debugging some CouchDB problems, I was looking for (still open) deleted files: $ lsof -nP | grep '(deleted)' And to my surprise I found that Google Chrome has around 16900 such files: 15870 files ...
-3
votes
0answers
32 views

Detecting the newest file in a directory [on hold]

I need a Unix script to do the following (in bash) : Accept 1 parameter; (the parameter can only be bo or bot.) Change directory (at this time, this can be determined yourself for now); Detect the ...
0
votes
1answer
35 views

Creating an symbolic link in /bin automatically creates a second link in /usr/bin and the which command chooses /usr/bin

I just created an executable: ln -s /path/to/script.sh /bin/script then I check if everything succeeds and it does(/bin/script is created) but this has also created: /usr/bin/script and if I ...
1
vote
1answer
43 views

Move files from multiple directories to another system

Let's suppose I have a folders in the source system: AB1, AB2, AB3. And I have the same folder names AB1, AB2, AB3 in the destination system. I want to move AB1 files to AB1 and AB2 files AB2 and ...
1
vote
0answers
19 views

How should I distribute files/packages/software across multiple drives?

I am primarily a Windows user, but I am starting to use Linux more as I realize all the features it has. In Windows, I install my software that I use regularly on my 120GB SSD, along with the OS, ...
0
votes
1answer
28 views

How to clear log files periodically

Hi I am new to Shell script. i want to clear log files in a directory basing on the dates. I have managed to gather this code: DIR1='/home/u01/app/oracle/servers/DIR1/logs' ...
0
votes
2answers
30 views

Where should startup scripts for a specific user be installed?

I have one script that will run when a specific user logs in. Where should this script and its assets be placed? I was planning to put it in /usr or /bin or /var, but I was wondering if there's a ...
0
votes
1answer
31 views

Directory Permission Order [duplicate]

In Linux, let us assume we have a directory with the following properties: drwx---r-x 29 user1 group1 4096 Jun 22 14:11 dir1 can I, as user2 having group group1, navigate into dir1? Since ...
2
votes
3answers
94 views

Delete several sequential file names, but ignore part of the first

Sometimes, my scripts get trapped in infinite loops. When the loop creates new files, things get messy. I currently have this file name format: Task.4883.store.log where 4883 is a counter. I ...
1
vote
2answers
62 views

How do I test if my variable is not in a set?

I am trying to modify the bash shell script and need some assistance. I have a directory with a bunch of files. What I need is to go through the files in a loop and if the file name not in a specific ...
1
vote
0answers
21 views

Process exceeding max open files limit

I am counting current open files by a process pid by :- cmd1:- ls /proc/$pid/fd/* | wc -l and then I am calculating percentage by fetching Max open Files limits. cmd2:- $ cat /proc/$pid/limits ...
1
vote
2answers
52 views

ldd says not found but .so file is in /usr/lib

When I type ldd with my executable file there is one not found warning. libCmp.so => not found libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6ed7000) libm.so.6 => ...
1
vote
4answers
46 views

Find text in a file and copy it to another file

Is there any command in Linux to find text in a file and if found then copy it in another file? Using sed -i we can find text but how to copy whole line in another file?
3
votes
2answers
60 views

Script for changing modification time of files and directories recursively

I have many big folders with thousands of files in them and I want to use touchto set their modification times to be "original time"+3 hours. I got this script from a similar thread in superuser: ...
1
vote
2answers
30 views

How to add some characters to filename via 'rename'?

For example I have a file named 5.jpg. How can I rename it to aaaaa.jpg with char a 5 times. I tried rename -v 's/(\d{1,})/a{$1}/g' * but this renames 5.jpg to a{5}.jpg, which is not what I want. I ...
-1
votes
1answer
20 views

How can I limit a log file to a certain number of most recent logs?

I know that you can limit the size of a file in respect to bytes, but I was wondering if there was a way to limit the number of logs within the file to, for example, the most recent 200 logs.
0
votes
1answer
35 views

How do I make 'sudo ll' work? [duplicate]

Every once in awhile, I find myself needing to list files in a directory that I don't have execution permission on. So I do a sudo: >sudo ll /opt/mydir [sudo] password for civfan: sudo: ll: ...
1
vote
1answer
18 views

How do you use 'find' to update ownership of all directories, files, and symbolic links in a folder?

I'm trying to update the ownership of everything in a directory tree from me to root. I'm using find to do it a little more carefully than a recursive chown. Here are the commands I use to change ...
2
votes
2answers
40 views

How can I shuffle pages from a pdf file in a random order?

I would like to shuffle the pages of a pdf document in a random order. How can this be done?
2
votes
1answer
23 views

How to guard a set of folders from being written into by a specific process?

I would like to have a way in which a set of folders do not allow write access for a particular process. For example, I would love to have a way in which YUM/RPM is not allowed to write into /usr/bin ...
1
vote
2answers
41 views

shell or perl script to check group have read privileges

ls -l drwx------ 8 ws web 1024 Apr 29 2013 abc drwxr-xr-x 8 ws web 1024 Oct 19 2011 def I need some script to find directories like abc which doesn't have read/execute permissions ...
4
votes
2answers
308 views

Where is the trash can for root partition?

I use trash-put to trash files from command line. Recently, I had aliased my rm command to trash-put so that I don't accidentally delete something important. However, what happened now was that I ...
1
vote
0answers
15 views

Allow move but not put in internal-sftp

is it possible with the internal-sftp to allow mv command from dir A to B but not allow put to A?
4
votes
1answer
31 views

Why can't another user access my file when it's a full path?

I have a program that runs a command that is something like this: /home/myuser/bin>> /usr/bin/sudo -u otheruser script.py /home/otheruser/file.txt This works, but now I need this to work when ...
2
votes
2answers
54 views

is it possible to search for files that have a special Linux file attribute?

is it possible to search file in the linux OS that have particular file attribute as this: ---S--l--- ---S--l--- 1 root root 0 Mar 1004:25/opt/csTuner/iba/wys/tuer_lolk What is S in ...
2
votes
2answers
35 views

One-liner to sort and uniq two outputs

I'm currently doing this to sort and uniq the output of two different commands: tshark -r sample.pcap -T fields -e eth.src -e ip.src > hello tshark -r sample.pcap -T fields -e eth.dst -e ip.dst ...
0
votes
0answers
19 views

Function dup2(int oldfd, int newfd) fails in for() loop [migrated]

I tried this for fun to see if it works but eventually it does not. i = open("something", O_RDWR); for(i ; i<10 ; i++); { if(dup2(i, i+1 ) == -1 ) { ...
3
votes
1answer
99 views

How do you deliberately trigger a “text file busy” error?

Very occasionally I encounter "text file busy" error while using my Linux 4.0.4 computer. I read that when the error happens, kernel is preventing modification to a file that is being "used". So I ...
0
votes
0answers
16 views

Archlinux: Gnome 3.16 - ls & nautilus incorrect sorting

Recently switched from Xfce 4.12 DE to Gnome 3.16 and I have a problem with dirs & files sorting in terminal and nautilus. Test directories (how it should be): [ Pqr ] Abc Klm My current order ...
1
vote
1answer
63 views

Permission denied writing to mysql log

I am just testing out a new Ubuntu (Vivid 15.04) install on Vagrant, and getting problems with mysql and logging to a custom location. In /var/log/syslog I get /usr/bin/mysqld_safe: cannot create ...
0
votes
1answer
43 views

How to create a bash script that sees all files in a directory and tells me their size and date of creation?

I'm a beginner in the field of programing/coding. I'm trying to write a simple bash script that will see all files in a directory, and then tell me each file's size and each of their dates of ...
1
vote
1answer
51 views

get original creation date of html file

Can I find the creation/last modified date of an html file? For example, I would like to know when some index.html file from some website was created, not when I downloaded it.
3
votes
0answers
9 views

Is posix_fadvice / POSIX_FADV_DONTNEED functional in Linux?

If I am doing once only scanning across big files then do I need to worry about impact on the page cache or does the OS take care to avoid my scan causing pointless churn in the page cache. I want to ...
3
votes
3answers
35 views

Create 2 similar-name files with content from 2-line output of a command

I perform cmd and it outputs 2 lines of text: $ cmd foo bar I need to write these to: `/long/path/x.{load,conf} Writing to this destination requires superuser privilege, which rules out manually ...
1
vote
1answer
29 views

How to see if a file has CAP_NET_ADMIN?

I ran the following command: sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip `which nmap` Now I'd like to add to my ~/.zshrc a line that detects such settings and exports ...
1
vote
1answer
22 views

What do you call the supervisord and php-fpm et. al. config format?

Both php-fpm and supervisord use a config format that looks like this: [category] settings = value some_other_setting = value Is there a name for this format?
2
votes
3answers
42 views

Move file and preserve owner and mode in one atomic operation

Is there a way to move a file and preserve original owner(group) and file mode in one atomic operation? So there will not be change for others to access moved file in time when is not already set ...
4
votes
3answers
79 views

Find largest files from each date in a directory

I have a directory similar to the following: -rw-r--r-- 1 root root 223K Apr 28 14:25 2015.04.28_14.25 -rw-r--r-- 1 root root 253K Apr 28 14:55 2015.04.28_14.55 -rw-r--r-- 1 root root 276K Apr 28 ...
2
votes
1answer
50 views

How to monitor the opening and closing of files?

I'm writing an AI personal assistant. One part of the software is a monitor daemon. A small process that monitor's user's active windows. I'm using python( with libwnck and psutils for obtaining info ...
45
votes
7answers
4k views

How are file types known if not from file suffix?

I would like to know how file types are known if filenames don't have suffixes. For example, a file named myfile could be binary or text to start with, how does the system know if the file is binary ...
1
vote
2answers
103 views

How to see if the directory exists?

How can I check if /bin/x86_64/bin/ls is a directory in a bash shell script Here is what I tried: #!/bin/bash if [ $# -eq 2 ]; then if [[ "$1" = /* ]] then cd ./bin/x86_64/bin/ls ...
0
votes
1answer
44 views

Remove files newer than X day and hour

I want to remove files, more specifically, symbolic links of /usr/include that are newer than 2 JUN 22:27 How can I do this?
3
votes
1answer
45 views

Deleting ghost files with non-ASCII characters

I have some weird files and folders in my trash on Mac OS X. After I "empty" the trash, the files still remain. I attempted to manually delete the files: $ cd ...
1
vote
3answers
62 views

How to scp all files of a certain owner?

I want to scp all files of certain owners. For example, if this is my ls -la output: -rw-rw-r-- 1 owner1 ad 704 Jun 1 18:16 file1 -rw-rw-r-- 1 owner2 ad 798 May 29 11:15 file2 -rw-rw-r-- 1 ...
3
votes
2answers
152 views

change file size format when using stat

The formatting character %s makes stat print the filesize in bytes # stat -c'%A %h %U %G %s %n' /bin/foo -rw-r--r-- 1 root root 45112 /bin/foo ls can be configured to print the byte size number ...
5
votes
6answers
110 views

How to find out whether two directories point to the same location

Do the following paths point to the same disk location? /home/username /app/home/username