Solved

Shell Script

Posted on 2011-02-24
9
222 Views
Last Modified: 2012-08-14
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
Comment
Question by:ratna1234
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:ssnkumar
Comment Utility
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
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
use

cut -f 1,2,6 < datafile > myfile
0
 
LVL 8

Expert Comment

by:ssnkumar
Comment Utility
@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
 
LVL 8

Expert Comment

by:point_pleasant
Comment Utility
there is of course the good ole awk command

awk '{ print $1" " $2" " $6 }'  filename
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 48

Expert Comment

by:Tintin
Comment Utility
awk '{print $1,$2,$6'} file >newfile

Open in new window

0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Typo in my last comment.

Should be:

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

Open in new window

0
 
LVL 8

Expert Comment

by:point_pleasant
Comment Utility
WOW

> newfile

really?
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
point pleasant,

not sure what you mean.
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
Comment Utility
bah, still had a typo

      

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

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now