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

learn more… | top users | synonyms (1)

1
vote
1answer
60 views

Single record of a file getting splitted over multiple lines

We are using flat text files to store in teradata table after transformations from Informatica. The file contains 14 fields (~ separated). But as the records are getting scattered over multiple lines ...
2
votes
1answer
47 views

Creating symlinks in the etc directory without root access

What I would like to create if I had root access would be a symlink from some file or folder in the /etc to another file or folder in the /etc. However, I do not have root access. Is there any way to ...
2
votes
2answers
66 views

Set default permissions by file type (at least in Vim) [duplicate]

When I create a new script, I always have to manually add executable permissions with chmod +x foo.sh. My default permissions are set to 644, and but I'd like any file with extensions like .sh .py to ...
1
vote
1answer
56 views

Very slow file operation

I recently rebuild a machine with Centos 5.8 with a brand new disk. This machine is old and has been running 5.8 for a long period with no issues so the only thing which changed recently is the new ...
1
vote
1answer
103 views

How to delete file called “-C” [duplicate]

I need to delete the following file which I managed to create with bunzip2: -rw-r--r-- 1 beginner group 67493376 Feb 17 17:30 -C The following don't work rm -rf '-C' rm -rf "-C" My OS is ...
1
vote
3answers
114 views

how to set up permissions of “download” dir to prevent execution of exploit program

There is a host with a local service that receives data from a remote location (via e.g. http) and saves it locally under /var/log/data/ in some mydir. $ ls -al /var/log/data drwxr-sr-x+ 4 root ...
1
vote
2answers
180 views

How do I wait for a file in the shell script?

I'm trying to write a shell script that will wait for a file to appear in the /tmp directory called sleep.txt and once it is found the program will cease, otherwise I want the program to be in a sleep ...
3
votes
0answers
34 views

Look at the bytes in a directory? [duplicate]

I would like to see what the actual contents of a directory file are (not the files that are contained within that directory). Specifically I would like to be able to do something like: od -c . ...
0
votes
1answer
119 views

Command to to restart Pantheon files manager (elemenaryOS)?

After editing context menu entries (by editing files in /usr/share/contractor) I have to restart the file manager to see the changes. How to restart Pantheon Files with a command so that I don't have ...
3
votes
1answer
74 views

How do you get the first file in each subdirectory matching a list of file extensions?

How do you get the first file in each subdirectory matching a list of file extensions? My goal is to run a program on just any one of the files in a series of subdirectories. For example, below ...
0
votes
0answers
28 views

Folder keeps vanishing/showing up in finder, terminal says it doesn't exist

Upon a standard find routine I noticed a folder kept returning errors, even tough it didn't contain any of the arguments in the search query. Ilha-VB2-leo:FESTIVAIS_01-16 ilhavb2$ find . -iname ...
0
votes
1answer
46 views

linux (general) file/directory rename/delete operations under os permission scheme

In linux, do file/directory rename/delete operations belong to write permission?
0
votes
4answers
56 views

What is the command to find the read/write permissions for a single file?

I know that ls -l lists the permissions of every file in a directory but what is the command if I want to see the permissions of just a specific file?
0
votes
1answer
125 views

How do I transfer images from Fedora 20 computer to iphone?

I have a laptop running Fedora20. I have an iPhone4S. I have installed the software suggested here which allows my laptop to read the iPhone. I connect my phone to the laptop using a USB cable. I ...
1
vote
4answers
74 views

Dynamically reference a file's name

In a single directory, I'd like to replace the first line of each file with the file's name. Each file has as the first line "TestRelation." I'd like to replace it with the file's name. I know I can ...
3
votes
1answer
45 views

“Ghost” files in ext4? (ktorrent allocated disk space)

I'm downloading with KTorrent, and have noticed that when I select "allocate disk space before starting torrent", it creates all the files at start, presumably empty, to avoid fragmentation. When I'm ...
1
vote
1answer
27 views

find's - cnewer broken on NTFS-3g?

After extracting an archive to the wrong place, I thought I'd erase everything created after it, but find . -cnewer archive.7z gave the wrong results. So I made a controlled test by touching three ...
2
votes
2answers
142 views

Mailx with multiple uuencode attachments and body

I am sending multiple files using following line in my script find . -type f -name "Sum*pdf*"|while read name; do uuencode "$name" "${name##*/}"; done | mailx -s "North Bus Correction" $RECIP Now I ...
0
votes
4answers
45 views

adding programs to path [duplicate]

I have a load of tools that are kept in the /opt directory. The tools are organised like this: /opt/toolname/tool.sh. My question is, how can I add the tools in my /opt folder to my path, so i can run ...
1
vote
1answer
66 views

Find which file contain a particular keyword using `grep`

Suppose I know I have to change myhostname = abc.domain.lcl to myhostname = abc.domain.glbl directive but I don't know in which file exactly the directive myhostname is in (i.e., say I have never ...
0
votes
2answers
82 views

Rename file by it is folder name

I have a sort of folders (A,B,C,D,E,F,G,H) and I have one file in every folder has the same name in all the folders (file.txt) but the size of this file is different from folder to folder. I wanted to ...
0
votes
1answer
81 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
23 views

Allow inclusion of file in php but forbid reading/editing by user

I have a file.php that needs the be kept in secrecy, so its permissions are 700. What I'd like to do is maintain these permissions 700 but allow the inclusion of the file in other files. How can I ...
3
votes
6answers
244 views

redirect output to specific line number

I want to grep certain lines by keyword and redirect the output to specific line number of an existing file. Command grep "key" temp_file >> desired.txt What I need is that I can append the ...
1
vote
1answer
86 views

How to import videos/pictures/documents from my Samsung smartphone to my Linux system?

I imported most of last year's videos and pictures from my Samsung Galaxy Note 3 to my Fedora 20 laptop through Gwenview import. Now I want to import the last month's but I'm having difficulty ...
3
votes
1answer
78 views

Filename expansion from date ranges

Consider dates in the ISO 8601 format i.e. ‘YYYY-MM-DD’, e.g. 2015-01-28, and say we have a folder with files of the form: AAAA_<date>_BBBB I am looking for a glob pattern in zsh (or Bash) ...
0
votes
1answer
63 views

How to use awk to read data between all frequent time intervals

I have a log file in following format [30/Jan/2015:10:10:30 +0000] 12.30.30.204 xff=- reqId=[-] status_check len=- GET /api/getstatus HTTP/1.1 mi=- ec=- 200 425 [30/Jan/2015:10:11:00 +0000] ...
2
votes
1answer
95 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
4answers
562 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
427 views

File limits getrlimit(RLIMIT_NOFILE) failed

(32-bit system) Posted a Q/A earlier regarding Chrome crashing because of exhausted limit in open files. Chrome has since run more smooth, (after increasing limit), but still crashes from time to ...
1
vote
2answers
155 views

Find unique files between two directories (recursively)

I am backing up files, and I have a lot of files duplicated in multiple locations. I've used fdupes to find duplicates, but I'm actually looking for some sort of inverse of this tool. I want to see ...
0
votes
1answer
146 views

Crontabbed shell script not able to create/write to a file

I have written a simple shell script to backup the tables in my DB using the mysqldump command. The command simply dumps the DB into a dbName.sql file. However, if the dbName.sql file doesn't already ...
-1
votes
4answers
437 views

How do I list files ending in txt only on Unix?

I have a directory with nine files in it. 1 ending in .bat 2 ending in .bak 4 ending in .txt 2 ending in .xtxt My question is, how do i list only the files ending in txt, but without the period. ...
5
votes
5answers
532 views

What are the root permissions for a file?

If I type: ls -l file.txt I see that the rights for that file are equivalent to "456": 4 = owner (r--) 5 = group (r-x) 6 = others (rw-) Which the rights for root in this case? Does it have 777? ...
0
votes
1answer
33 views

Deleting a file object from a library

I've created a library with 3 file objects using: ar rv arhiva.a file.o file2.o file3.o Why I can't delete a file object from it? I've used ar xv arhiva.a file.o
1
vote
1answer
255 views

Rename files based on directory names

How can I rename .jpg files in multiple folders based on the name of the folder? I also want the .jpg files to remain in their respective folders and not moved. The folder names have no spaces. So, ...
10
votes
5answers
945 views

How to get the last N files in a directory?

I have many files that are ordered by file name in a directory. I wish to copy the final N (say, N=4) files to my home directory. How should I do it? cp ./<the final 4 files> ~/
1
vote
1answer
33 views

output log file from some time to some time via ssh

I have a access_log which size is neally 2GB. I want to analyze it from 2015:09:55 to 2015:09:57, but during this period, there have more than 500 items. So I want to output and download the ...
1
vote
1answer
38 views

How to upload to a unix server?

Im a part of a project group, and one of our tasks is to upload some content to a server. I am completely new to this and have some questions. There are content on different servers(distributed on ...
1
vote
2answers
323 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 ...
3
votes
2answers
193 views

How to remove “lock” from deleted, but still used files on Linux?

SERVER:~ # df -mP /home/ Filesystem 1048576-blocks Used Available Capacity Mounted on /dev/mapper/rootvg-home_lv 496 491 0 100% /home SERVER:~ # SERVER:/home # ...
2
votes
3answers
59 views

How to determine if a soft link's target is a directory or a file?

Given the ll command outputs as follows #> ll lrwxrwxrwx ... How to determine if a soft link's target is a directory or a file from "lrwxrwxrwx"?
-1
votes
1answer
45 views

Show the content of a file in the mail body

I am writing a script where it shows the content of file in the body of the mail. But i am getting error while I am executing it. RECIP="abc@gmail.com" lines=`wc -l $HOME/totals` if [ $lines == 6 ...
0
votes
1answer
26 views

Many files in folder - time difference while accessing file with fullpath

Folder /var/log/something may have 1 file (test.log) in it or 1000000 different files (and test.log of course). Is there a time difference while accessing file test.log with realpath between those ...
3
votes
3answers
116 views

Get modification date that can be used with touch -m

I need to get the modification date of a file so that I can set it on other files using touch -m. stat or perl -le 'print((stat shift)[9])' Didn't return what I wanted. I think that you are supposed ...
0
votes
1answer
326 views

Bash script, ask for user input, to change a directory, sub directorys, and file's mtime atime linux recursively

Using GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) I am a bash scripting novice, not sure where to begin except at shebang #!. The following command. touch -a -m -t 201501010000.00 ...
1
vote
7answers
314 views

Remove a specific extension from all the files in a directory

I have a couple of files with ".old" extension. How can I remove the ".old" extension without remove the file? I can do it manually but with more work: mv file1.key.old file1.key mv ...
1
vote
1answer
94 views

Read from character delimted file and assign into variables | for email

I am using ksh. I need to read the data from file, into the variables and then further use them for sending emails. File can be delimited by any less used characters (like | ^ etc.) or group of ...
2
votes
1answer
266 views

Chrome too many files open / crash / Sorry Jim

When using Google Chrome I frequently get “Sorry Jim” tabs. The browser also frequently freezes and crashes. Running it from terminal emulator show a long line of Too many open files: ...
1
vote
3answers
48 views

How to access the contents of a file that is used as an argument when running a bash script?

I am running a bash script with its parameters/arguments as files. From inside the script, how do I get the contents of those files? I run the script with this command line: sh script_name ...