OT: unix newbie questions

G

Gerard Flanagan

Hello all

Some basic unix questions which pure laziness prevents me from googling
for. Anyone feeling charitable? I'm using FreeBSD 6.0:

* To create an empty __init__.py file I do 'vim __init__.py' then
immediately exit vim, is there a shell or vim command which will create
an empty file without opening the editor?

* If I want to do :

mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz

then tab-completion gives me the first occurrence of the file, but I
have to type the second occurrence - is there a way of not having to
type it?

* cd ~ brings me to my home directory, is there a means by which I can
set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^
to get to that directory?

* I'm using the tcsh shell and have no problems with it, but bash seems
more popular - any reason to change? (I don't intend writing many shell
scripts)

* Any other unix/vim tips for a 'nix newb?!

Thanks in advance

Gerard
 
R

Rene Pijlman

Gerard Flanagan:
* To create an empty __init__.py file I do 'vim __init__.py' then
immediately exit vim, is there a shell or vim command which will create
an empty file without opening the editor?

touch __init__.py
* cd ~ brings me to my home directory, is there a means by which I can
set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^
to get to that directory?

You could create an alias in your shell.
 
D

Diez B. Roggisch

* If I want to do :
mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz

then tab-completion gives me the first occurrence of the file, but I
have to type the second occurrence - is there a way of not having to
type it?

No need to give it the name the second time.

# touch foo
# mkdir d
# mv foo d
# ls d
foo
#

Diez
 
J

Joel Hedlund

* I'm using the tcsh shell and have no problems with it, but bash seems
> more popular - any reason to change? (I don't intend writing many shell
> scripts)

You can do this in bash:
$ python myprog > stdout.txt 2> stderr.txt

and have output to sys.stdout and sys.stderr go in separate files. Quite handy
for separating output and debugging comments. I believe that this is impossible
in tcsh (where you only can do $ python myprog &> stdout_and_stderr.txt to
catch stdout and stderr at the same time).

Also: bash_completions. It keeps track of arguments and options for commonly
used programs and commands. If you type "cd " and hit tab for completions you
will only see directories, since bash_completions knows that this is all cd
accepts. Don't know if tcsh has anything similar.

Cheers,
Joel Hedlund
 
I

Inyeol Lee

]
* If I want to do :

mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz

then tab-completion gives me the first occurrence of the file, but I
have to type the second occurrence - is there a way of not having to
type it?

In this specific case you don't need second filename.

mv mypackage-1.0.2.tar.gz subdir/

is enough. If you need filename for some reason, use this.

mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz.backup

=>

mv mypackage-1.0.2.tar.gz subdir/!#:1.backup

This works for both bash and (t)csh.


--Inyeol
 
L

Lawrence D'Oliveiro

"Gerard Flanagan said:
* To create an empty __init__.py file I do 'vim __init__.py' then
immediately exit vim, is there a shell or vim command which will create
an empty file without opening the editor?

man touch
* If I want to do :

mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz

then tab-completion gives me the first occurrence of the file, but I
have to type the second occurrence - is there a way of not having to
type it?

This is not how bash works. bash lists all the possible completions.
* cd ~ brings me to my home directory, is there a means by which I can
set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^
to get to that directory?

You could set up a variable, e.g. in bash

export w=/usr/local/www

then

cd $w
* I'm using the tcsh shell and have no problems with it, but bash seems
more popular - any reason to change? (I don't intend writing many shell
scripts)

Last time I used tcsh, its autocorrection facility kept making wrong
suggestions. I just don't think it's worth using any more. Stick to bash
for all your shell needs, both interactive and scripting, and leave it
at that.
* Any other unix/vim tips for a 'nix newb?!

Try emacs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top