nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

unable to cut required field 1 from this output

This is a discussion on unable to cut required field 1 from this output within the Shell scripting forums, part of the Development/Scripting category; Hi Everyone, I am just unable to cut the 1st field. I require to cut the 1st field to work ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 08-18-2005, 06:27 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default unable to cut required field 1 from this output

Hi Everyone,
I am just unable to cut the 1st field. I require to cut the 1st field to work on that specific job-id, but I am just unable to do it.

I think there is something wrong in the o/p file generated.

Code:
job-ID  prior   name       user         state submit/start at     queue     slots	 ja-task-ID 
-----------------------------------------------------------------------------------------------------------------
    466 0.55500 runit38    user1         r     08/16/2005 10:22:25 comp1-3@comp1-3.cha     1        
    467 0.55500 runit39    user1         r     08/16/2005 10:22:25 comp1-3@comp1-3.cha     1        
    468 0.55500 runit40    user1         r     08/16/2005 10:22:30 comp1-4@comp1-4.cha     1        
    469 0.55500 runit41    user1         r     08/16/2005 10:22:30 comp1-4@comp1-4.cha     1        
    470 0.55500 runit42    user1         r     08/16/2005 10:22:35 comp1-5@comp1-5.cha     1        
    471 0.55500 runit43    user1         r     08/16/2005 10:22:35 comp1-5@comp1-5.cha     1        
    465 0.55500 runit37    user1         r     08/15/2005 18:17:35 comp1-3@comp1-3.cha     1        
    472 0.55500 runit44    user1         r     08/16/2005 10:22:35 comp1-4@comp1-4.cha     1        
    473 0.55500 runit45    user1         r     08/16/2005 10:22:40 comp1-4@comp1-4.cha     1
If I pipe the above o/p to cut -f1 -d" " . It displays only
Code:
job-ID 
------------------------------------------------------------------------------------------------------
and doesnot show anything below the line

Can anyone pls see what could be wrong with the out put or is there anything else to do with the options of cut.

Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-18-2005, 06:39 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,034
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

When output filed has more blank spaces or it change location then it is better to use awk which is pattern-directed scanning and processing language. For example print username from /etc/passwd using : as field separator
Code:
awk -F: '{ print $1 }' /etc/passwd
Coming to your specific example, use awk as follows:

Code:
awk '{ print $1 }' filename.txt
cat filename.txt | awk '{ print $1 }'
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 08-19-2005, 12:06 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

Thank you Nixcraft.

It worked. Pls don't mind if I ask too many things you all think are actually trivial.

I am new to this all and believe me, I am very happy that I get help from the members of this forum. As for now, I am still learning and hope that one day I can surely help someone else.

Thanks again for the help.
Reply With Quote
  #4 (permalink)  
Old 08-19-2005, 04:31 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,034
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Noop we don't mind qestions... so keep posting all your questions (read my sig)
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
squid report required jhn_daz@yahoo.com Networking, Firewalls and Security 1 02-11-2008 05:31 PM
About iptables output satimis Networking, Firewalls and Security 0 09-30-2007 09:30 AM
shell scripts required for students roni Shell scripting 6 07-20-2007 07:21 PM
How to redirect Output puppen Shell scripting 15 12-06-2006 09:44 PM
required linux email help vaishalichitale Linux software 4 06-20-2006 02:20 PM


All times are GMT +5.5. The time now is 05:13 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36