-2

edit:

Thanks guys - so if I do "ls J*", why doesn't that list all the files beginning with J?

I just want to copy directories beginning with the letter J into another folder in my (cshell) terminal window? It must be one quick line surely, but I can't seem to get it to work, nor can I find the answer online.

Can someone put me out of my misery please?

user1551817
  • 6,693
  • 22
  • 72
  • 109
  • well first I tried listing them with "ls ./J*" but that just gave me loads of other filenames. The I tried doing a loop: "foreach file ('ls -1 | hgrep J') cp -r end" but I got a message about "missing destination file operand after – user1551817 Sep 28 '12 at 08:28
  • yeah the directories and everything in them – user1551817 Sep 28 '12 at 08:29

2 Answers2

2

Shell globbing?

cp -r J* /path/to/other/dir
nneonneo
  • 171,345
  • 36
  • 312
  • 383
1
cp -r J* /destination/path/

the -r option lets you copy directories recursively

Karim
  • 151
  • 1
  • 5