[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Shell Script

Need a script for below .

896019990060000001 502195560000001 43197381 1234 1234 48694743 DFC40A06BB8A2B63A63A98E5B3ACD4BA 03300349
896019990060000002 502195560000002 07536851 1234 1234 54280393 C781699B7735B9D8B30D1B4BAE970344 56623200
896019990060000003 502195560000003 29000945 1234 1234 29681079 356EEB858937C38B4A4C9245E89D68D7 78562572



I want to print col1 , col2 col 6 sepratly to a file they are seprarted by single space.
0
ratna1234
Asked:
ratna1234
  • 4
  • 2
  • 2
  • +1
1 Solution
 
ssnkumarCommented:
cut command on Unix/Linux will do this.
Use -f and -d options to indicate the field and the delimiter (in your case this is space or ' ').
0
 
omarfaridCommented:
use

cut -f 1,2,6 < datafile > myfile
0
 
ssnkumarCommented:
@omarfarid: I could have also given the full command with all the options. The reason I didn't give the full command is, it will be like doing the homework!
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
point_pleasantCommented:
there is of course the good ole awk command

awk '{ print $1" " $2" " $6 }'  filename
0
 
TintinCommented:
awk '{print $1,$2,$6'} file >newfile

Open in new window

0
 
TintinCommented:
Typo in my last comment.

Should be:

awk '{print $1,$2,$6'} file >newfile

Open in new window

0
 
point_pleasantCommented:
WOW

> newfile

really?
0
 
TintinCommented:
point pleasant,

not sure what you mean.
0
 
TintinCommented:
bah, still had a typo

      

awk '{print $1,$2,$6}' file >newfile

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now