Solved

How to do this

Posted on 2002-06-06
3
271 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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 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…
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…

737 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