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
2answers
37 views

First and last five lines of file [duplicate]

How to see first and last 5 lines of file? Right now I am using head filename ; tail filename Any other way around and more efficient?
-4
votes
1answer
43 views

how to move all files under one directory to home directory

I have the script files script1.ksh ...script10.ksh in the directory star2 PATH : home/aaa/star2 I need to move all the files under star2 to the home directory (home/aaa) NOTE : I do not want the ...
4
votes
1answer
55 views

Split file and know how many files were generated

I'm using the following lines to split a file into smaller parts: split --line-bytes=100M -d $input $output/FILENAME echo "$input was split into ??? 100MB files." >> demo.log After that, I ...
1
vote
2answers
79 views

Why doesn't unix filesystem store creation time of a file? [duplicate]

Is there any historic reason? Stat stores last accessed time, last modified time and last changed time , but not the creation time! Isn't that important information. I can't understand why the ...
0
votes
1answer
60 views

Size of a character/block file

Why is the size of a character or block file given as comma separated? crw-rw-rw-. 1 root root 1, 3 Mar 8 10:15 /dev/null brw-rw----. 1 root disk 8, 1 Mar 8 10:15 /dev/sda1 Size of a file is ...
2
votes
1answer
97 views

Why is this find command not returning filenames containing non-ASCII characters only?

I'm trying to determine the root cause of why this find command is not working; it shouldn't match the file called this_should_not_match below: $ > find . -type f -name "*[^ -~]*" ./__º╚t ./...
2
votes
1answer
43 views

Searching Files according to PNG Meta-Tags

As stated in the title, I want to search for PNG's in a (sub-)folder structure with the meta tag software set to the value GNOME::ThumbnailFactory and delete them with a single bash command. Have ...
4
votes
1answer
61 views

Identify files/processes that prevent remounting read-only

My system runs Debian Testing, and / is generally mounted as read-only. The main problem with this is, every time I install something or update the system, I cannot remount the filesystem (I get the ...
0
votes
1answer
84 views

recover files if still being used by a process

I have run into a problem where I accidentally erased the contents of a conf file. I am trying to use the cp and tail recovery process that I saw online but it does not appear to be working. The file ...
1
vote
1answer
122 views

Find tar.gz files in a folder which are older than 20 days and delete

I have a backup script which creates a backup (in tar.gz) of my /var/www-folder in my CIFS-mount-folder. To delete old backups which just waste memory I have created a cronjob that checks every day ...
-1
votes
1answer
44 views

Accidentally moved file to `,` (comma)

I logged in as a root user and when moving a file, instead of: mv myfile . I entered mv myfile , And now my file is gone but I am not sure where to. Where has it moved to?
1
vote
2answers
34 views

Reorganizing lines in a text file

So I have the following file: First Line Second Line Third Line 3 0.374 2 0.777 1 0.245 Fourth Line 4 0.687 ... And I want to reorganize it so the lines beginning with an int are appended to the ...
3
votes
2answers
49 views

Is it possible to display directory contents automatically while typing command?

I'm new to Linux. I wonder if it is possible to make terminal display directory contents automatically while I typing a command with directory arguments? For example, if I want to do cp ./fileA ~/...
0
votes
4answers
72 views

How to merge one directory into other?

May somebody tell me if there is there some way to "merge" one dir into another? I.e. let I have /some/directories/structure with subdirs/files. And now I want to "implantate" it into /etc for ...
0
votes
0answers
27 views

How do I hook an application and find out what files it writes while running? [duplicate]

I'm not sure how to exactly word this question, because my searching hasn't yielded anything that describes my situation what I'm looking for. Say my friend writes an application and sends it to me ...
1
vote
1answer
29 views

How do permissions on a directory affect files in it?

I just learned something that shocked me, because I did not have a clue it was a fact. If I have a directory with the following permissions: user@host:~$ ls -la testdir total 8 drwxrwxrwx 2 user ...
1
vote
3answers
239 views

Cannot remove <file>: No such file or directory

I just ran some self-written program in which I make files and fill them with stuff. However, I did something wrong (or at least, not as intended) with the name generation and now there are four files ...
-1
votes
4answers
177 views

Why does linux use file extension to decide the default program for opening a file though it's independent of file extensions

I have a text file as- abc.text and it has its contents as Hi I'm a text file. If I double click to open this file, then the files is opened in gedit editor. Whereas, if I rename the file to abc....
0
votes
1answer
59 views

Compare and tar file for 2 date formats from filename

I need to keep files 4 months from now (3 previous month + 1 current month) in directory and tar the rest. But the problem is my files consist of different format. StockList_03-01-2015.txt Ref_01-02-...
-1
votes
2answers
68 views

Finding the number of files in a folder [duplicate]

How can I find a number of files in a folder, assign it to a variable, then echo that variable, all in one command line?
-1
votes
2answers
37 views

Can we recover the data which has been truncated [duplicate]

Can we recover the data which has been truncated by >hello.log. Please help.
3
votes
2answers
258 views

Alter certain bytes in many files

I need a large number of damaged .png files in order to test my project. To that end, I need to set all bytes from the 0x054-th to the 0xa00-th to 0. .png files contain chunks with checksums, I want ...
-2
votes
3answers
82 views

Move files based on filename into directory Year/Month/Day

I have files in the format YYYY_MM_DD_HH:MM:SS.swf that dump into a folder /home/user/dump/ I want to move these files into a new directory tree /home/user/save/year/month/day/ based on the ...
3
votes
2answers
431 views

Alternate solution for making multiple copies of a single file using command line?

I am trying to copy a file to 10 files. Say for example I have a E-mail message named test1.eml. I want 10 copies of the same file. When I searched in internet, I came across this stackoverflow ...
0
votes
2answers
46 views

Vim writes to file without having permissions [duplicate]

$ ls sess.vim -lh -rw-r--r-- 1 root root 11K Feb 26 18:52 sess.vim I want this file to be readable for everyone and writable by no one (except by root). Thus I set its permissions to ...
3
votes
3answers
59 views

I want to grep out a text string from many files, how can I run a loop for this

I have a thousand .xyz files, all numerical data and in the same directory. Some of them have the text string "END" at the very end of them. I'm not sure how to loop a grep command so that it removes ...
0
votes
1answer
36 views

Alias for checking if folders in one directory exist in another

I'm trying to create an alias that will check if all of the folders in one directory are also in another directory and if not, tell me which ones aren't. This is what I'm trying: alias files_not="...
3
votes
4answers
93 views

How to delete a specific number in file?

I have a file: 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 1 2 5 6 8 0 0 0 0 I want delete all zeros: 1 2 5 6 8 1 2 5 6 8 1 2 5 6 8 1 2 5 6 8 I tried tr -d [:0:]. Unfortunately, it ...
2
votes
3answers
85 views

Suppress filename from output of sha512sum

Maybe it is a trivial question, but in the man page I didn't find something useful. I am using Ubuntu and bash. The normal output for sha512sum testfile is <hash_code> testfile How to ...
-4
votes
1answer
54 views

linux error flag in permission denied thing [closed]

Even after running the command sudo chmod -R 777 /home, I cannot fix the error: Sorry, user kumarht1 is not allowed to execute '/bin/chmod -R 777 /kumarht1' as root on host.com. How should I fix ...
49
votes
8answers
6k views

On Unix systems, why do we have to explicitly `open()` and `close()` files to be able to `read()` or `write()` them?

Why do open() and close() exist in the Unix filesystem design? Couldn't the OS just detect the first time read() or write() was called and do whatever open() would normally do?
-2
votes
2answers
60 views

How do I keep the /lib folder clean?

I have been installing libraries for use with c programs. Is there a way to keep the /lib folder clean? Can I use subdirectories, links, etc to manage this? It's getting pretty cluttered, I'm not ...
1
vote
1answer
53 views

Access directory by modification date

Is there a way to refer to a directory by its modification date, like cd ~/$newest/subdirectory? I know that I could (and shouldn't?) parse ls, and I currently just use a hacky script that generates ...
1
vote
1answer
31 views

Set maximum number of processes started by incrond

I am using incrond to monitor a directory for incoming files. After each file arrives in the directory a python script is called to process it. A problem arises when the rate of incoming files is ...
3
votes
2answers
67 views

How to copy modified files while preserving folder structure

I have made many changes to files in my PHP project and I want to push those changes to our server via FileZilla FTP. Rather than push all of the files, I would like to find only the files that have ...
6
votes
1answer
555 views

Check last time .sh file used

When you run ./myscript.sh is that considered as "access" time? I need to know the last time a script was run, but I'm not sure if this counts as mtime, ctime or atime (differences described here).
5
votes
4answers
293 views

Join two files on two common fields

I have two files file1.txt 78Z|033333157|0000001|PERD1|2150421|D|0507020|3333333311 78Z|033333157|0000001|PERD0|2160208|A|1900460|3333333311 78Z|033333157|0000001|RSAB1|2150421|D|0507070|3333333311 ...
2
votes
1answer
73 views

Does adding the content at the start of file result in updating all the data blocks?

In the Unix File system (UFS), the file is represented as an inode structure which has 15 pointers that reference the direct blocks or indirect blocks. Taking the below images is an example. Each ...
4
votes
3answers
318 views

Copy only certain file types from a folder structure to another

I have a top folder with many sub-folders. It's named "a". There are many .png and .jpg files in there. I'd like to recursively copy "a" into a new folder "b", but only copy the .png and .jpg files. ...
2
votes
2answers
141 views

sudo tar changes extracted files ownership to unknown user

I am running this command: $ sudo tar xvzf nexus-latest-bundle.tar.gz The extracted files belong to an unknown (1001) user: drwxr-xr-x 8 1001 1001 4096 Dec 16 18:37 nexus-2.12.0-01 ...
0
votes
1answer
56 views

Can we merge binary files without any copy operation by handling filesystem?

I would like to merge efficiently binary files using a shell command and I quickly found classical ways like this one : cat file1 file2 > file3 Not bad but : It's slow. IO access are slow. It ...
1
vote
2answers
56 views

To find the size of some group of files

I was trying to find out the total size of all files which are owned by a particular user. While trying so, i get different sizes when executing different commands. Which command is correct to find ...
-2
votes
1answer
33 views

How to get files from broken directory? [closed]

I created some files and directories on external NTFS HDD using Ubuntu. Some folders displayed with cross sign, I changes permissions for them (777), now they just as a files. Copying of directory ...
1
vote
1answer
63 views

Search a string in files in the current directory, omit duplicates

Assuming I want to write a line which prints out lines which match a specific string without repeating duplicate lines .. I want to search for this string in the files of the current directory: grep ...
0
votes
0answers
16 views

Script to combine two files output to parallel output [duplicate]

I would like to get it so that: $ cat file1.txt a b c $ cat file2.txt 1 2 3 results in: $ cat out.txt a1 b2 c3
1
vote
1answer
35 views

Bourne Shell do while loop returns all the data but has two errors no such file or directory and repeats the shell name

The idea of my loop is to print the first digit of every line of a file. The file being this: 256-56-8411 Bob 3.61 Junior CS 471-44-7458 Tim 3.45 Senior CE 326-...
0
votes
2answers
41 views

Executable file isn't “really there” after rsync [duplicate]

I am issuing the following rsync command (obfuscating the exact path & host), which should copy two binaries: rsync -e "ssh -p 443" -a --info=progress2 -z user@remote:/srv/cgi-bin/ . user@remotes'...
0
votes
2answers
102 views

Help creating script to move files based on date or filename

I have an FTP process that is constantly putting files into a directory. The date created is part of the filename in a format like this: YYYY-MM-DD-HH-MM-SS-xxxxxxxxxx.wav I would like to move the ...
4
votes
6answers
156 views

Sort files by highest number in filename

I've got a bunch of files all named like this: name_file-1.txt name_file-2.txt name_file-3.txt some_other_file-1.txt some_other_file-2.txt There are thousands of different filenames, some with just ...
0
votes
2answers
32 views

Bulk rename, change suffix? [duplicate]

How can I bulk replace the suffix for many files? I have a lot of files like NameSomthing-min.png NameSomthing1-min.png NameSomthing2-min.png I would like to change all them to NameSomthing.png ...