How can we create a empty file with the unix name -stuff. It means the name start with -. I tried with touch -stuff but it didn't work.
1688
How do you remove a file whose filename begins with a dash (hyphen or minus) -?  I'm ssh'd into a remote OSX server and I have this file in my directory:  tohru:~ $ ls -l total 8 -rw-r--r--    1 me  staff  1352 Aug 18 14:33 --help ...   How in the world can I delete --help from a CLI?  This issue is something that I come across in different forms on occasion, these files are easy to create, but hard to get rid of.  I have tried using backslash  rm \-\-help   I have tried quotes  rm "--help"   How do I prevent the minus (dash or hyphen) character to be interpreted as an option?
88290
Somehow a file named -]???????q got created on my terminal. I tried  rm -f "-]???????q"  (in double quotes), but it did not get deleted. (Error::  rm: invalid option -- ]).  How do I delete it?
50133
I would find it very convenient to be able to use cd with a file argument.  cd myDirectory/anyname.anyExtension would be equivalent to cd myDirectory/  What would be the best alias or function to achieve this behavior ?  EDIT: Sorry I didn't mention it in the 1st place: I use zsh
83149
If I have a file which name starting with single or several minus sign, for example --1 it can't be used as a parameter of many commands. Even if I run  cat --1   instead of file content I get unrecognised option error message:  cat: unrecognized option '--1'   Same effect appears when I type  cat "--1" cat '--1' cat \-\-1   nothing works. Files starting with '-' is not illegal in file system, but it is quite hard to work with them in cli and scripts. OK, in case of cat or grep I can use  cat &lt;--1   and this will work, but  rm --1   won't work either and it is quite hard to substitute this command with something else. Very uncomfortable after all. Is there any universal workaround different from not using such file names?   BTW, if name file is single - and all most of commands will understand it as stdin, wouldn't they?   And it would be hard not to use such file names since I can't rename them all in script using mv command either.
65833
(I'm using Windows XP but I guess it's similar in all the recent versions of Windows.)  When you create for example a new empty text document, you'll find in its properties that it has size of 0 bytes. Zero bytes means no information. No data. But still, the file has some name, it can still carry the dates of last access, modification and creation. It carries the information whether it's hidden file or not, whether it's read-only or not...  So where are all the metadata stored?
97449
I want to write the Ubuntu analogue of a "batch file" (a shell script). But I don't know how to use chmod +x filename command to make it so that the script can be run. Nor do I know where to use it.
108031
Let's say one creates a file like so:  touch myFile   You enter some text in it with vim or whatever, and then use cat myFile to spit the contents out into the terminal.  Now, what happens when I use cat on any image?  Say,  cat myPNG.png   I just get a bunch of garbage.  It just made me think about what the cat command is attempting to do, and where all of this "garbage" comes from.  Just curious.
8236
Whilst i have found posts that tell me how to add a new context item for a specific file type, i seem to be unable to see a way of adding one for a blank file (a la ubuntu).  Is there a way of adding just a blank file (with no extension), which i can then rename myself with the appropriate extension?
73573
How can I create an empty file from the command line?
1435
Last night I discovered what looks like an unusual file named "~" (tilde) in the root of my "Macintosh HD" directory on my MacBook.    Finder reports the file is 2.2MB in size, of kind "TextEdit.app Document", and was created on 22nd January 2014 (so about a month ago).  I haven't noticed any operational issues with OS X or it's applications.   I haven't yet touched the file but would obviously like to remove it.  I am very conscious that '~' is a special alias to the user home directory and thus I would appreciate any recommendations in removing the file in a safe manner that isn't likely to nuke my home directory or screw up the operation of applications or OS X. I don't know whether to delete or rename and whether to use Finder or the command line.   It's entirely possible that I created the file by accident since I've recently been drafting and running various shell scripts that use the ~, user home alias.  MacBook Pro 15" (Retina, Mid 2012) Yosemite
44386
I have a directory filled with various files, differently named (i.e. not named with a specific pattern) and with different extensions, and I want to put each file in a newly created subdirectory named after each file; what's the best way to accomplish that from the command line under Linux? This sounds a bit confusing, let me make and example: let's call a random file in the directory ./filename.ext, I'd like to put it in a subdirectory called ./filename so that effectively the new path will be ./filename/filename.ext.  I did some trials with the following steps:   I've created some test files, from file-1.txt to file-9.txt, inside a test directory with for num in {1..9}; do touch file-$num.txt; done  I've created a directory named after each filename with for name in $(eval ls | cut -b 1-6); do mkdir $name; done I've moved the source files in their respective directories with for name in $(eval ls | grep -e ".txt" | cut -b 1-6); do mv $name.txt $name/$name.txt; done   As you can see, this solution works, but its huge drawback is that it works just in this case, with files of that extact filename lenght and with that particular extension. If I have some files with different names and extensions, this would be of no use at all. The use of cut command is not the ideal solution here, I suppose, but I haven't found anything better at the moment.  As a bonus, it would be cool to find a way to create the subdirs automatically when moving/renaming the files, without having to use mkdir previously (so when I ls to actually rename, I don't have to worry about excluding the newly created directories); but in the end this is a secondary problem.
94237
I was trying to find how to pass some text to a file without overwriting what's there already using the > command and I realised I don't know what it's called. Searching for right arrow or right chevron or more than command didn't show up anything. I've always just called it pass to.
2796
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 following line that should work, but because of it dash it doesn't:  for file in -N*.ext; do mv $file x$file; done   If I put an echo in front of the mv I get a bunch of  mv -N1.ext x-f1.ext mv -N2.ext x-f2.ext   Which is correct, except of course it will think the first filename is options. So when I remove the echo and run it I just get a bunch of  mv: illegal option -- N   I have tried to change it to  for file in -N*.ext; do mv "$file" "x$file"; done   but the quotes are just ignored it seems. Tried to use single quotes, but then the variable wasn't expanded... What do I do here?  Update: I have now also tried to quote the quotes. Like this:  for file in -N*.ext; do mv '"'$file'"' '"'x$file'"'; done   And when I echo that, it looks correct, but when I actually run it I just get  mv: rename "-N1.ext" to "x-n1.ext":: No such file or directory   I have just no clue how to do this now... sigh
21080
I got a bunch of files with the filename messed up. All the file names have the same beginning which appear to be windows file directories. The problem is there are 700+ files and I really don't want go through and manually rename all of them. These are examples of the file names (Note: None of these have file directories):  G:some\really\long\file\path\then\the\name1.jpg G:some\really\long\file\path\then\the\name2.png G:some\really\long\file\path\then\the\filename.txt G:some\really\long\file\path\then\the\file_name.mov ...   The important take away is that each file has G:some\really\long\file\path\then\the\ before the file name that I would like.   So I would want the above files to look like:  name1.jpg name2.png filename.txt file_name.mov   I've tried the rename command and was not successful. I am still new with Linux and really am not sure on how to go about it or really what to google. Any help would be appreciated.
83007
For example I have a file called fileNames.txt.  cat &gt;fileNames returns  abet  able  abacus   How do I use fileNames to create abet, able, and abacus as .txt files?  I tried using pipes with cat and touch.
117651
Accorging to GNU documentation:  ‘\&lt;’ Match the empty string at the beginning of word. ‘\&gt;’ Match the empty string at the end of word.   My /etc/fstab looks like this:  /dev/sdb1       /media/fresh      ext2   defaults     0 0   I want grep to return TRUE/FALSE for the existence of /media/fresh. I tried to use \&lt; and \&gt; but it didn't work. Why?  egrep '\&lt;/media/fresh\&gt;' /etc/fstab   Workaround:  egrep '[[:blank:]]/media/fresh[[:blank:]]' /etc/fstab   But it looks uglier.  My grep is 2.5.1
98998
I need to do create a file with a filename such as :&gt;?, is this possible somehow? Windows stops it.