Tagged Questions
1
vote
2answers
41 views
Unix moving/removing files from subdirectories
if there are several subdirectories in the current working directory, i would like to move only specific filetypes or possibly all the contents of those directories, to the working directory. and ...
1
vote
1answer
28 views
OSX / Unix: move odd or even numbered files
I have a folder with a range of numbered files (camera images) and I'd like to move every other image into a different folder, so either all the odd numbered images, or all the even ones. How can I do ...
0
votes
0answers
10 views
Recover modified file
I'm using sublime text 2 to sync between local and remote site version. Something went wrong, and a source file became empty (0bytes). Is there
0
votes
5answers
27 views
Rename a file based on the owner - linux/Unix
I have several files in a folder that all follow a naming convention of:
rs1.txt
rs2.txt
rs3.txt
Some of these files were produced by myself, and some were produced by my colleague.
I was ...
0
votes
1answer
38 views
UNIX command to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4
Need help with the UNIX command below to sort the file by the following words, from major sort key to minor sort key: word 3, word 1, word 4. (words are separated by white spaces)
sort -t -k3 -k1 ...
2
votes
3answers
198 views
How to edit the header of a huge CSV file in-place?
I have several huge CSV files in which I want to swap two column names.
I do not want to modify/copy/rewrite the data.
The operation is very cheap in C: fopen the file, fgets the header, fseek or ...
0
votes
3answers
40 views
Extra file with Same Name Created Automatically while writing a program in unix
Some time while writing a program for example
convert.c a file with same name followed by tiled(~) convert.c~ gets created in same directory. why is this so and whats really happening .please explain ...
0
votes
1answer
189 views
Cant remove/delete symlink
I have tried to create a symlink and it threw this error:
ln: accessing `.test': Permission denied
Now I can't unlink or delete the symlink file.
Tried Googling for help but could not find a ...
0
votes
1answer
93 views
Prevent mv from overwriting the larger file by the same name
I need to move all files from a directory, discarding the directory structure.
Unfortunately, some files have the same file name (Thumbnails).
I'm looking for smth. like this:
find /tmp/dirtree ...
92
votes
18answers
5k views
What's the quickest way to count the number of each character in a file?
I want to count the A's T's C's G's N's and "-" characters in a file, or every letter if needed, is there a quick Unix command to do this?
6
votes
1answer
174 views
Is it possible to 'instantly' create arbitrary files?
I've seen the following trick to create large, empty files somewhat quickly:
dd if=/dev/zero of=test.dat bs=1024 count=1024
However, this still takes some time when creating multi-GB files. I ...
1
vote
1answer
59 views
How to create a file with symbols in its name
How can I create a file starting from $SHELL, using quotes like " ",' ', \?
I tried, but it's not working.
1
vote
1answer
123 views
Delete all files that don't start with a certain string in a folder
How can I delete all files that don't start with "2012" in a particular folder?
This is on OS X Lion.
2
votes
1answer
119 views
What is a socket link?
After noticing an interesting environment variable Apple_PubSub_Socket_Render. I notice that it was referring directly to this "Render" file.
After doing a listing of "Render":
ls -lh Render
I ...
2
votes
1answer
856 views
copy same file into multiple directories - permission denied error
Please help me in solving the below issue:
I want copy a file say info.txt into multiples directories and their sub-directories .
I used this command:
go to parent directory.
find . -type d -exec ...
3
votes
5answers
1k views
sorting files by size in a dir
how can I display the files in a unix directory sorted by their human readable size, going from largest to smallest?
I tried:
du -h | sort -V -k 1
but it does not seem to work. thanks
1
vote
1answer
1k views
how do I compress all files within a folder on Unix?
I've been unable to compress the contents of a folder on Unix, note that I don't want to compress the directory itself but the contents inside.
so far.. to compresss the files I use:
compress ...
0
votes
3answers
72 views
Is there any file I can read in unix which contains the time
Is there any file in unix based system which I can read, to get the same value that time() in php would return?
3
votes
4answers
3k views
Linux ls to show only filename date and size
How can i use ls in linux to get a listing of filenames date and size only. I don't need to see the other info such as owner, permission. Is this possible.
1
vote
1answer
107 views
Setting the last file status change time
stat will report the last access time, last data modification time, and last file status change time.
utimes will allow one to set the last access time and last data modification time.
Is there a ...
2
votes
1answer
202 views
Attributes of a file
I am trying to determine what all of the attributes are of a regular file (as opposed to a symbolic link, etc.) on Mac OS X with Mac OS Extended (Journaled) (HFS+). Here is my current list:
...
4
votes
1answer
3k views
How do file permissions apply to symlinks?
Let's say you have this structure:
+ directory
-- file1
-- file2
-- file3 -> /tmp/file3
file3 is a link to another file3 somewhere else on the system.
Now let's say I chmod 777 the directory ...
4
votes
3answers
1k views
why do we need execution permission to change a directory in Unix
Here are the permissions given on the machine:
drwxrwxrwx 4 root root 512 May 16 09:32 STC_10
drwxrw-rw- 4 root root 512 May 5 11:22 STC_11
Now here is the Problem:
cd ...
0
votes
1answer
275 views
Perform a math operation on all numbers in a file
I have a list of pixel values in a file, and need each to be half its current value. The pattern for the value is always 123px where 123 varies drastically.
How can I half each pixel value?
I'm ...
4
votes
3answers
926 views
Escape files output for compatibilty with 'xargs'
I have this command:
find $1 | xargs touch
But files with ' characters in their names fail with "xargs: unmatched single quote", and I guess other special characters would cause the same problem.
...
2
votes
1answer
1k views
How can I (on Mac/Unix/Linux/scripting) recursively copy a directory into another and replace only the files that have not changed?
Background and issue
I moved to Mac OS X recently and bumped into the "feature" of Mac where copying files from an external drive resets the file modification/update date/timestamp to the current ...
0
votes
3answers
158 views
Unix/Mac [bash/c api]: detect if a given path points to a file on a removable device
Is there a *nix command or C api that will tell the type of the storage device given the path to the file (resolving the mounts, symlinks, etc)? I need to find out whether the file lives on a ...
5
votes
2answers
671 views
How to create a file with a “#” character in the name in Unix?
I've tried many commands already for creating a file and deleting a file with a # character, but it does not work. Can anyone tell me the command to create and then delete a file that begins with #?
1
vote
2answers
2k views
Find and remove all empty files
How can I search all empty files of non-root system and delete them?
7
votes
6answers
5k views
How to delete all but one file in Unix? [duplicate]
Possible Duplicate:
How to delete all files in a directory except some?
How to delete all but one(or some) file in Unix ?
Something like
rm -rf -ignore myfile.txt *
4
votes
4answers
703 views
Renaming files in batch with Unix RENAME
I have files whose names look like this:
Sim1-2_40.36.chr20_sb.foo.indel.novoalign.sam
Sim1-2_40.36.chr20_sb.foo.indel.bwa.sam
What I want to do is to replace all indel with snp in the names
...
1
vote
4answers
890 views
Tool to monitor file read/write in unix
Is there any tool/command available in unix to monitor read/writes in a particular file.
I also want to collect how much data is being read each time the file is accessed.
2
votes
5answers
3k views
How do I show the header of a file in Unix?
guys, in order to see the header of file (wmv,mp3, binary[pe/elf/machos], avi, etc....) which command line in unix could perform this ?
looking forward for some answers :D
1
vote
1answer
226 views
Tail the filename, not the file
In UNIX (OS X BSD to be precise), I have a "tail -f" command on a log file. From time to time I want to delete this log file so I can more easily review it in my text editor.
I delete the file, and ...
15
votes
4answers
15k views
How can I find files that are bigger/smaller than x bytes?
In a terminal, how can I find files that are bigger or smaller than x bytes?
I suppose I can do something like
find . -exec ls -l {} \;
and then pipe the result to AWK to filter by file size. But ...
2
votes
2answers
2k views
How do I close a file that I created using cat > command?
I learning how to use git on a Mac and I'm trying to add a file in one of my branches by using the "cat > " command. The problem I'm having is that I want to end editing the file in the terminal but I ...
0
votes
3answers
115 views
Which directories are private to specific users by default on UNIX-based systems?
Which directories and files in UNIX-based file systems have default user permissions set? For example, a user's home directory can't be seen by other users on a system without his permission. What ...
1
vote
2answers
105 views
How to download files from command line?
For example, see this page Advanced Linux Programming.
I want to download all the pdf files linked from this page. Is there a simple commandline way of doing it?
Something on the lines of
download ...
0
votes
1answer
356 views
When attempting to open any file with WinSCP, it attempts to list it as a directory
We had a security breach and some things were messed up on our Ubuntu servers. Now, when I log in to two of our servers using WinSCP and I double-click on a file to open it with my default ...
26
votes
3answers
34k views
How to make new file permission inherit from the parent directory?
I have a directory called data. Then I am running a script under the user id 'robot'. robot writes to the data directory and update files inside. The idea is data is open for both me and robot to ...
0
votes
3answers
4k views
How to create a cron job to upload files to an FTP server
I would like to create a cron job that uploads files from a directory on my computer to my FTP server. I would like it to do it daily at midnight. I know pretty much nothing about cron, so I ...
5
votes
1answer
988 views
Unix: Files starting with a dash, -
Ok, I have a bunch of files starting with a dash, -. Which is not so good... and I want to rename them. In my particular case I would just like to put a character in front of them.
I found the ...
4
votes
3answers
160 views
Why does this bash command take up all space on device?
I'm a little new on searching via bash, so feel free to give me suggestions on the methods to use instead of this, which I'll never use again :)
I'm searching for occurances of a string, recursively ...
4
votes
1answer
301 views
Unix: softlinks, hardlinks
I am somewhat confused what the differences between a softlink, and a hardlink are (on unix).
It seems like a softlink is the same as a shortcut in windows or an alias on Mac OS X. (Can someone ...
0
votes
3answers
90 views
Unix: How to check the existence of a tag at the beginning of each file before insertion?
The question is related to the question "Unix: Add a Tag to the beginning of each file?".
How can I put the tag only to the files that do not contain the tag, such as <?php, already?
5
votes
5answers
2k views
See history of who all opened a particular file
How can I know who opened a particular file recently but might not have kept it opened at the moment?
Anyone has an idea?
1
vote
2answers
435 views
Unix File Permissions issue
I want to set permissions such that whenever a directory is created by a 'user' then its default permissions should be 775.
But when that 'user' creates a new file then default permissions should be ...
8
votes
8answers
2k views
Mass renaming, *nix version
I was looking for a way to rename a huge number of similarly-named files, much like this one (a Windows-related question) except that I'm using *nix (Ubuntu and FreeBSD, separately). Just to sum up, ...
2
votes
1answer
84 views
Local links ( in browsers ) on *nix systems
On Windows I can access files directly from the browser ( or at least I have it configured currently, forget if it was native like this ) with the file:// protocol, so I can access files from say the ...
1
vote
3answers
1k views
Modification of files with 777 permissions but not with 755 permissions?
I can modify the files with 777 permissions, but not with 755. I do it by sourcing some sed commands. I find it odd because I can modify the files with even 700 permissions in Vim.
Why is it not ...
