shell commands...

magomago

Lifer
Sep 28, 2002
10,973
14
76
okay this is what i want to do-

i have a folder with c1 hrough c30

i want to do this:


ls c* > cfiles


this creates a file called cfiles with the names of anything with a c* dumped in it.

but the file includes all the output and some uncessary information such as file size and permissions...and each file name isn't on one line

is there any way that i can get it to dump one file name per line and nothing else without having to do this manually? this is on an SGI running IRIX 6.5 - so actually using a unix variant but i'm sure the shell isl argely the same ;)
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
i believe that with GNU ls, there is a flag of -1 to get one line per file. i would also guess that you have ls aliased to ls -l if you're getting file size and permissions. you might see if you have such an alias set up.
 

Tarrant64

Diamond Member
Sep 20, 2004
3,203
0
76
Originally posted by: CTho9305
echo c* | sed -e 's/ /\n/g;' > cfiles

This is why I stay away from linux. I don't have anything against it of course. I work with it from time to time. And occasionally run Ubunutu.
 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
Originally posted by: Tarrant64
Originally posted by: CTho9305
echo c* | sed -e 's/ /\n/g;' > cfiles

This is why I stay away from linux. I don't have anything against it of course. I work with it from time to time. And occasionally run Ubunutu.

you stay away from linux because it has a usable command shell with powerful text manipulation tools?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
'find . -maxdepth 1 -name 'c*' > filename' would be easier to understand than CTho9305's solution.
 

Tarrant64

Diamond Member
Sep 20, 2004
3,203
0
76
hmm...

i stay away from linux because rarely do i need a usable command shell with powerful text manipulation tools.

just my thought, but...i'd love having to give help desk support to someone over the phone that was using linux.

of course, then i would just ssh in to do the work myself.

still don't like it.
 
Dec 29, 2005
89
0
0
i've never used irix, but if it behaves the same way that other versions of unix do, it seems like what is happening is that ls is aliased to ls -l (which is somewhat common, it is more common however aliased to ll). if this is in fact the case you can either unalias the command before you issue it (which is probably not a good idea), or force it to not use the alias (which i unfortunately forgot how to do, and i don't have a unix terminal i can login to right now, i think if you put the command name in single quotes it will work, like this: 'ls' ). however the caveat i issued before is that if the ls command in irix behaves like ls in unix/linux, but if it doesn't, then none of this information will be relevant :(
 

magomago

Lifer
Sep 28, 2002
10,973
14
76
Originally posted by: Tarrant64
hmm...

i stay away from linux because rarely do i need a usable command shell with powerful text manipulation tools.

just my thought, but...i'd love having to give help desk support to someone over the phone that was using linux.

of course, then i would just ssh in to do the work myself.

still don't like it.

Actually *nux is INFINITELY more powerful for what I want it right now. I need to dump about 30 file names for files that represent bone contours into a text file for about 111 samples to run it through a finite element analysis model....

I would kill myself if I had to do it the "windows" way --> ie: opening up notepad and manually typing them all.
Typing this one command is a LOT faster and doesn't spend time doing mundane tasks...this way I will most likely type "cd .. && cd DIRECTORY && echo c* | sed -e 's/ /\n/g;' > cfiles && vi cfiles && autofem2004" and I can quickly switch between each directory and execture it all with ONE line....(i need to edit the cfiles file because it also dumps "cfiles" in there ;) ) and the program I use I have to actively input stuff depending on the sample i'm dealing with...

honestly I have no idea how i'd do that in windows...although I know its easily done in linux, and i'm sure its easily possible to setup a script that will go through each directory so ultimately I run the script and from then all I do is make changes in VI and choose the relevant options in the fem program....rather than my brute force method of multiple && ;)

so it may look complex- and I sure as hell don't understand what the stuff says right now...but its easier and FASTER that is ultimately the main thrust in improving an OS..to make things easy and fast.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
just my thought, but...i'd love having to give help desk support to someone over the phone that was using linux.

of course, then i would just ssh in to do the work myself.

Exactly, you wouldn't have to walk them through anything other than possibly booting the machine because you have 100% control via ssh.

still don't like it.

That's your perogative, but it makes no sense because you just admitted that remotely supporting Linux users would be easier.

or force it to not use the alias (which i unfortunately forgot how to do, and i don't have a unix terminal i can login to right now, i think if you put the command name in single quotes it will work, like this: 'ls' ).

That seems to work too, but I think the preferred way in sh is to escape he command, i.e. \ls.

I would kill myself if I had to do it the "windows" way --> ie: opening up notepad and manually typing them all.

Actually 'dir /b > blah.txt' would probably work for him on Windows.