Hi
John Carlyle-Clarke wrote:
> > I am a cli dunce so please bear with me.
Ignoring all the cheats that just used the command line to start a GUI,
sometimes as root!... :-)
> > m...@computer:~#/folder1/folder2/folder3/folder4/folder5 mv blah
> > blah.........
> >
> > Now I want to go back to work in folder2, what the easy command to
> > get me back there??
Are you aware of the shell's filename completion with the Tab key?
After typing
cd /fo
pressing Tab may well complete more of the path for you because there's
only one unique choice, e.g.
cd /folder
will now be present leaving you to enter the "1". If Tab can't complete
any more then it will beep. Pressing it again may make it list the
alternatives. (This varies between shells and can be tailored too so I
can't be specific.)
If I'm hopping about or referring to places I'll use shell variables.
(An alias to change directory gives me only that.) An easy way to set
them is
cd /some/long/path
d=`pwd` # Note, these are backticks.
...
cd $d
...
mv *.c $d
although annoyingly you'll have to wrap the definition of d and all uses
of it with "" if the path includes a space. Don't put spaces into
directory or file names! :-) Plan 9 banned them in the kernel, wisely.
cd /some/long/really stupid/path
d="`pwd`"
...
cd "$d"
...
mv *.c "$d"
If I have a big bunch of files in the current directory and want to
spread them around other directories without an obvious pattern, e.g. in
filename or content, then I'd go into vi, do
!!ls<Return>
to get the list of files, one per line, and then edit up the file until
it was a bunch of mv invocations, one per line. Perhaps put a `set -e'
at the beginning and then do
gg!Gsh<Return>
to run the whole lot of lines through a shell. If all the lines
disappear there were no errors.
> Another way is to use the pattern:-
>
> find <stuff> -exec <command> '{}' \;
>
> That's a bit odd looking, but <command> gets executed for each file
> found, replacing '{}' with the name.
The braces don't need quoting, saving some fiddly typing, as shells
don't perform brace expansion on an empty {}. Probably due to find's
use of them pre-dating the C shell's introduction of brace expansion.
Cheers,
Ralph.
--
Next meeting: Somewhere quiet, Bournemouth, ???day 2010-12-?? 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
How to Report Bugs Effectively: http://goo.gl/4Xue