13
votes
3answers
2k views

Why isn't there any shell command to create files?

Attention please: I am not asking how to make a file from the command line! I have been using touch for making files for years without paying attention that its main purpose is something else. If ...
2
votes
2answers
67 views

How to rename filename with ' or ? in file name?

I have a problem renaming a file that I'm not even sure which special characters I have in the file. I'm using CentOS 6 64bit. When I ls the file: Giko Suzo San?e - Ep1.avi but when view it in ...
0
votes
2answers
42 views

file(1) command termination when using the -f - option

Say I'd like to use the file -f - command inside a script, and send some input using the stdin, when I'm finished I'd like to terminate it gracefully, but unfortunately I haven't found any way to do ...
2
votes
1answer
66 views

Copy files based on date/time from subset of directories

I'm teaching a class where (~80) students are submitting assignments that I can access via webdav, organized by student in directories named by their unique identifier. The students are split into ...
2
votes
3answers
40 views

How to get a list of applications associated with a file using command line

File associations usually are made in the desktop environment, but how to get a list of applications associated with a file using command line? Something like: $ getassoc foo.pdf <CR> $ ...
0
votes
2answers
67 views

How can I concatenate all files in a directory together in one command line operation? [duplicate]

I have 1000 csv files in a directory. I would like to concatenate them all together in order. They are named img_size_1.csv to approx img_size_1000.csv This answer is close but assumes a list file. ...
6
votes
5answers
741 views

How does one find out how many bits a file has in one command?

I know I can use ls -lat to find out how many bytes has a file and then multiply by 8 to find out how many bits. But is this possible in only one command line?
-1
votes
4answers
69 views

Need a command sequence that will move files from one directory to another based on a particular year? [closed]

I'm looking for a sequence of commands (one liner would be ideal) which will identify all the files created in particular year, and move the resulting files to another directory.
0
votes
1answer
193 views

Delete all 'nohup.out' within a directory recursively

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.
4
votes
4answers
182 views

How to randomly sample a subset of a file

Is there any Linux command one can use to sample subset of a file? For instance, a file contains one million lines, and we want to randomly sample only one thousand lines from that file. For random ...
2
votes
3answers
171 views

Can't cat a file or make a directory: contradictory output?

I am getting output from a terminal in Ubuntu 12 that I don't understand. $cat sublime no such file or directory $mkdir sublime cannot create directory 'sublime': File exists How can both of these ...
2
votes
3answers
148 views

What command do I use to see the start and end block of a file in the file system?

Is there any command that will output the beginning and ending blocks of any file?
2
votes
2answers
183 views

get age of given file

How can I get the age of a given file in, at least, days? I'm well aware of ls -lh and similar commands. I want something that will work sort of like this: getfage <FILE> # prints out '12d' ...
15
votes
2answers
1k views

How do I create a test file with lots of zero bytes

I know how to create an empty file: touch /var/tmp/nullbytes but how can I create a 1MB file that only contains nullbytes?
1
vote
3answers
76 views

Generate File of a certain size?

I'd like to generate a file with the name example.file. I could use touch example.file but I want the file to be exactly 24MB in size. I already checked the manpage of touch, but there is no ...
0
votes
2answers
76 views

Using Pipeline to Direct Files to Program that Opens Them

I have a Music folder, in which I have some music tracks, which aren't organized too well. Thus, if I want to find a particular track, I usually type: ls Music | grep <keyword>, where ...
0
votes
1answer
36 views

In which way is a commented line active in a program file?

To solve the bug reported here the solution seems to be commenting, not just adding a certain line in a file - as explained here and here. That is - to make that bug disappear in Xfce, a certain line ...
0
votes
1answer
80 views

Get a clean list of files transferred from rsync

I'm trying to get an itemized list of files transferred by rsync. Using the -i and --out-format options, I'm instead ending up with output that looks like this: 3HMP1MO_001.tif 974.68K 100% ...
3
votes
2answers
424 views

Automatically moving files to a directory, one by one, and only when the target folder is empty

Is it possible? And in reverse alphabetical order? Essentially, this: How can I move files by type recursively from a directory and its sub-directories to another directory? Except that each file is ...
1
vote
2answers
194 views

MacOsx - Shell - list all .php files and their octal permissions, inside a specifc folder

is it possible to list all the ".php" files located into a direcotry and their octal permissions? I would like to list them like this: 775 /folder/file.php 644 /folder/asd/file2.php etc...
6
votes
4answers
817 views

View permission / owner of full directory tree

I remember doing someting like "XXX /home/user/dir/child/file" and it returned the owner and/or permission of: /home /home/user /home/user/dir /home/user/child /home/user/child/file But I don't ...
0
votes
3answers
43 views

how to touch files like report-07/05/13

when I want to touch files like report-05/07/13 with command touch report-$(date +%D) it gives me an error like this: touch: cannot touchreport-07/05/13': No such file or directory` How can I build ...
1
vote
2answers
124 views

How to strip directory structure with command line (or script)

I have a large collection of files packed into a two-level directory structure with many, many, many folders. In other words, I have a folder with a great many subfolders in it. There are no ...
2
votes
5answers
149 views

Create and open file with one command?

I want to create a text file and open it in a text editor with a single command. I know touch file.txt creates a file and open file.txt opens the file, but is there a way to do this with a single ...
2
votes
1answer
1k views

Better way to copy multiple directories to new directory

Is there a better way on the command line to essentially accomplish the following but with a single command cp -r css/ ar/ cp -r images/ ar/ cp -r js/ ar/ cp -r backups/ ar/ I've just been ...
3
votes
4answers
4k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
1
vote
1answer
38 views

Can one move a relpath in one command?

This question is similar to one I asked recently, but the answers to that question, for the most part, do not extend to this one, AFAICT. The main difference between the two questions is that the ...
1
vote
2answers
335 views

Can one copy a relpath in one command?

I find myself doing this often enough that I wonder if there's a standard Unix way to do it: % mkdir -p /TARGETDIR/relative/path/to % cp ./relative/path/to/somefile /TARGETDIR/relative/path/to In ...
4
votes
8answers
912 views

Run a command on all subfolders

If you have a series of subfolders (like from a to z) and want to run a command on each one of them (like rm *.pdf or ls *.pdf), how do you do that? The "manual" approach would be cd a, rm *.pdf, or ...
5
votes
2answers
511 views

A command line utility to visualize how fast a file is growing?

I want to grok how fast a particular file is growing. I could do watch ls -l file And deduce this information from the rate of change. Is there something similar that would directly output the ...
-1
votes
3answers
2k views

Determine whether a particular file is compressed

How to know in Linux whether a particular file is compressed or not using a command?
4
votes
3answers
321 views

Filesize difference of same name folders

Two different folders, have the same name but they have different filesize. Is there any linux command that can compare two folders and tell me the diff in filesize at the same time?
1
vote
2answers
564 views

ALT+F2 doesnt work in Linux Mint Mate

I am trying to install Sublime Text 2 on Linux MINT (Mate) from this tutorial. http://community.linuxmint.com/tutorial/view/907 and I'm stuck on: Next , to create a menu icon press Alt+F2 and type: ...
2
votes
2answers
220 views

Sort the output of find before piping to openssh

I'm using this command to recursively generate a SHA-512 hash for each file in a directory hierarchy: find . -type f -exec openssl sha512 {} \; I'd like to sort the files in lexicographical order ...
4
votes
3answers
509 views

id3v2 used recursively at command line?

Trying to get my id3 tags cleaned up and am loving id3v2 on the command line -- but I've been using it only with a *.mp3 wildcard and want to explore if there's a way to use it recursively so I can ...
2
votes
1answer
425 views

Regarding generating intersection and union of two csv files

I have two csv files, there are some overlap columns between these two files. Assume one file is called as A.csv and another is called as B.csv. The intersection of A and B is called as C. I would ...
2
votes
2answers
654 views

How to make duplicates with different names from a single file? [closed]

I want to duplicate the contents of a file. Suppose there is a file named "Hydrogen.element". I want to duplicate the contents of this file with a different name ie.make another file named ...
29
votes
3answers
16k views

How to tell gzip to keep original file?

I would like to compress a text file using gzip command line tool while keeping the original file. By default running the following command gzip file.txt results in modifying this file and renaming ...
8
votes
2answers
5k views

Locate and delete all temporary files in user directory

I use vim a lot, and my area has power failure a lot. So the resultant is I get many *.swp files scattered over my PC. I want an alias of rm command that removes all files with either .swp, ~, ...
3
votes
3answers
209 views

Regarding separate a single file into multiple files according to line separation

Currently, I have a plain text file, A, such as lowest priority very high significance. outstanding very novel In this file, every line contains a sentence. I want to separate this file into ...
17
votes
12answers
19k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
12
votes
1answer
4k views

ls taking long time in small directory

Running Ubuntu, I open a terminal and do sudo bash cd / ls | head -n 1000 And predictably about 20 directories are returned. However, if I do an ls, and don't pipe it into anything, the ls just ...
5
votes
1answer
288 views

How to replace a symbolic link with an equivalent hard link?

Having a (single, no batch filesystem processing needed) symlink, what a command line to use to turn it into a hard link to the same file?
4
votes
1answer
919 views

How to replace a symbolic link with a copy of a file it links to?

Having a (single, no batch filesystem processing needed) symlink, what a command line to use to replace it with a copy of the file it links to?
2
votes
5answers
309 views

Is it possible to reference the most recently modified file in a command line argument?

I frequently download PDF files with heinous numeric file names from my browser. These automatically go into ~/Downloads. Ideally I would like to just be able to open these files with: evince "the ...
3
votes
2answers
1k views

How to execute one command on all files within a folder

Saying, I have this tree and I want to execute ruby on all scripts within the folder. How could I archive through one line of command. ./ ../ rb-script/ sample1.rb sample2.rb
3
votes
1answer
403 views

gvim -p limit of opened tabs?

When I run : gvim -p *.xyz I find that not all files are opened in tabs. It feels, like a kind of tab limit? But ! When I try to open unopened with : :tabnew it is opened next to previous ...
2
votes
2answers
143 views

Index names of all the files in a plain text file

I've got this directory full of images, and I can do this: echo *.jpg image1.jpg image2.jpg image3.jpg # and so on How can I get the output in a plain text file in this format? image1.jpg ...
3
votes
2answers
1k views

Obtain .avi file info from command line

What is the best way to obtain information as bitrate, framerate, width/height of an movie file (in my case .avi) from the command line? I am looking for a basic tool that works similarly as ...
5
votes
3answers
359 views

Shortcut for fast recursive removal

Sometimes I want to delete large swaths of temporary files recursively, and recycle the directory name without waiting for the command to complete. (For example, if I want to nuke and re-checkout a ...