Solved

How to do this

Posted on 2002-06-06
3
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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.

691 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