Solved

How to do this

Posted on 2002-06-06
3
251 Views
Last Modified: 2010-04-21

I have a file like this

001 name_01
002 name_02
003 name_03

The output that I need from this file above is :

001  002  003

How do this in a shell command ? I prefer it to do it with sed or awk.
Thanks for help
jvras
0
Comment
Question by:jvras
3 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 7061335
Here is what you need to do:

assume that your file name is: test.txt

type in:

cat test.txt | awk '{print $1} | tr "\012" " " > test.tmp
echo "" >> test.tmp
mv test.tmp test.txt

This should work for you.

0
 
LVL 5

Accepted Solution

by:
ecw earned 50 total points
ID: 7061371
 echo `cut -d' ' -f1 file`
or
  awk '{printf("%s" $1)}END{print}' file
0
 

Author Comment

by:jvras
ID: 7061745

ecw is giving me the just answer.
Thanks
jvras
0

Featured Post

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

Join & Write a Comment

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

747 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

10 Experts available now in Live!

Get 1:1 Help Now