Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 27
awk / grep / Prints all columns except the first one

I have the a file with the following data.

File Content.
1249 snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3
1248 sns06.3.0 sw version 1.1 code MD5 192F MD12
1250 sns06.3.0 sw version 1.1 code MD5 192F0\ MD8
1241 sns06.3.0 sw code MD5 19
1243 sn06.3.0 sw version 1.1 code MD5 19
12 ss06.3.0 sw version 1.1 code MD5 192F
129 ss06.3.0 sw version 1.1 code MD5 192
139 sns06.3.0 sw version 1.1 code MD5 19
1219 se06.3.0 sw version 1.1 code MD5 19

I want to remove the first column from that file and my file should look like below.

Can someone help me how to Print all columns except the first one

Output file
----------

snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3
sns06.3.0 sw version 1.1 code MD5 192F MD12
sns06.3.0 sw version 1.1 code MD5 192F0\ MD8
sns06.3.0 sw code MD5 19
sn06.3.0 sw version 1.1 code MD5 19
ss06.3.0 sw version 1.1 code MD5 192F
ss06.3.0 sw version 1.1 code MD5 192
sns06.3.0 sw version 1.1 code MD5 19
se06.3.0 sw version 1.1 code MD5 19

Thanks in advance
Sponsored Links
  #2 (permalink)  
Old 02-28-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370

Code:

cut -f2- -d ' ' input_file

  #3 (permalink)  
Old 02-28-2008
matt.d's Avatar
Registered User
 

Join Date: Feb 2008
Location: /dev/null
Posts: 62
What does the hyphen after "-f2" do?
  #4 (permalink)  
Old 02-28-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
It means: print all the fields (separated by space) starting from 2 and ending at the end of the line.
  #5 (permalink)  
Old 02-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 27
There are Blank Spaces at the beginning of the file as well
so
cut -f2- -d ' ' file_name doesn't work

My requirement is I dont want the first column and everything after that till the end of the line I would like to see as an output.

so Except $1

awk '{print $2 till end of the line}' filename

File Content.
1249 snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3
1248 sns06.3.0 sw version 1.1 code MD5 192F MD12
1250 sns06.3.0 sw version 1.1 code MD5 192F0\ MD8
1241 sns06.3.0 sw code MD5 19
1243 sn06.3.0 sw version 1.1 code MD5 19
12 ss06.3.0 sw version 1.1 code MD5 192F
129 ss06.3.0 sw version 1.1 code MD5 192
139 sns06.3.0 sw version 1.1 code MD5 19
1219 se06.3.0 sw version 1.1 code MD5 19
  #6 (permalink)  
Old 02-28-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,115

Code:

awk '{ for(i=1; i<=NF; i++) {printf("%s ", $i)}
          print $NF
       } ' inputfile > outputfile

  #7 (permalink)  
Old 02-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 27
There are blank spaces in the beginning of the line and after the end of first column. as shown below <BS> Blank Space
My output file should not contain the first column at all.


File Content.
<BS> <BS> 1249 <BS> snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3
<BS> <BS> <BS> 1248 <BS> sns06.3.0 sw version 1.1 code MD5 192F MD12
<BS> <BS><BS> <BS>1250 <BS>sns06.3.0 sw version 1.1 code MD5 192F0\ MD8
<BS> <BS>1241 <BS>sns06.3.0 sw code MD5 19
<BS> <BS>1243 <BS>sn06.3.0 sw version 1.1 code MD5 19
<BS> <BS>12 <BS>ss06.3.0 sw version 1.1 code MD5 192F
<BS> <BS>129 <BS>ss06.3.0 sw version 1.1 code MD5 192
<BS> <BS>139 <BS>sns06.3.0 sw version 1.1 code MD5 19
<BS> 1219 <BS>se06.3.0 sw version 1.1 code MD5 19
Sponsored Links
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
using Grep for only a certain number of columns MaestroRage UNIX for Dummies Questions & Answers 2 02-13-2008 02:24 AM
KBarcode prints labels as well as barcodes Linux Bot UNIX and Linux RSS News 0 01-16-2008 05:50 AM
Printer prints blank pages George26 UNIX for Dummies Questions & Answers 6 07-07-2006 10:53 AM
Prints Problems on Unix system ddameron UNIX for Dummies Questions & Answers 1 04-28-2005 04:37 PM
Screen prints on SunOS 5.7 grayson Solaris 1 09-18-2003 09:44 PM



All times are GMT -4. The time now is 04:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0