3

I have a text file like this:

1 http 2 3 4 5 
2 dns 3 4 
3 ftp 3 4 5 6 8 

I want the output to be like this:

http 2 3 4 5 
dns 3 4 
ftp 3 4 5 6 8 

Node that I just want to omit the first column in that file and the fields number in a certain line is not fixed.

Can I accomplish this goal using awk?

Yishu Fang
  • 8,258
  • 13
  • 57
  • 93

5 Answers5

2

You can also use cut: cut -d' ' -f2-.

Edit: If you have to use awk, try awk '{$1=""; print $0}'

Cong Wang
  • 1,863
  • 11
  • 11
0

something like this maybe?

awk '{$1 =""; print }' file
Maksim Morozov
  • 53
  • 4
  • 13
0

If you don't care about the the field separators remaining in place, you can do this:

awk '{$1=""}1' filename

(Assuming filename is where you stored your data)

freetx
  • 143
  • 4
0

Drats, I was going to give you an Awk solution, then recommend cut. It looks like others have beaten me to the punch.

However, I see no sed solution yet!

$ sed -n `s/^[^ ][^ ]*//p` yourfile.txt
David W.
  • 98,713
  • 36
  • 205
  • 318
0
sed 's/^..//g' your_file

above should work based on the condition that the first field is always of a single character.

or in perl:

perl -pe 's/^[^\s]*\s//g' your_file
Vijay
  • 59,537
  • 86
  • 209
  • 308