![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Career Guidance | sufi_431 | What's on Your Mind? | 1 | 10-23-2007 07:54 AM |
| NIM Guidance | scottsl | AIX | 1 | 06-12-2006 08:18 AM |
| Sed help needed | stevefox | Shell Programming and Scripting | 5 | 12-04-2005 09:44 PM |
| Looking for guidance in obtaining a job in Unix Administration | pkali290 | SCO | 4 | 12-08-2003 11:51 PM |
| select in ksh, any guidance for bash? | Shakey21 | UNIX for Dummies Questions & Answers | 1 | 05-09-2002 09:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
A little guidance needed :)
Hi guys, I'm learning the ropes of BASH and am doing a few exercises to see if its sinking in but have gotten stuck on something I KNOW is looking at me right in the face but just isn't registering.
I'm creating a script that needs to get specific strings from a line. So using the "ls -l <filename>" command, i get a string with 6 fields (permissions and so forth). No i know there is a way to get an individual field from the 6 fields and store it but i just cant remember it. I believe its a pipe to the grep command but I'm unsure and for all i know there is an easier method. Any help would be appreciated! Code: str = $(ls -l <filename>) #To get the info now i just need to "split" the data - if it was perl, easy enough :P. Edit: No AWK or SED. |
| Forum Sponsor | ||
|
|
|
|||
|
Indeed you could call it something like that.. Still if I'm not going to get anywhere sitting around and fiddling about then i may as well ask. Otherwise im not learning anything .. just wasting a bit of time.
Cheers non the less! Code str=$(ls -l <filename> | cut -d ' ' -f 1) -d Delimiter (space in my case) -f fields (1st one in my case) Just a brief explanation if someone was stuck on a similar situation. Last edited by shadow0001; 03-07-2008 at 07:35 AM. |
|
|||
|
I tried that however it did not work - brought up the entire line with out the option. Unix doesn't like me very much lol.
A final (i hope) question. If i had the work "command" and i wanted to split it into characters, how would i go about doing this ? See i need to be able to process each character individually using a loop however i am not aware of a command that allows me to do this. Thanks again. |
| Thread Tools | |
| Display Modes | |
|
|