How to print file without first column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print file without first column
# 1  
Old 09-09-2011
How to print file without first column

Hi, unix Gurus,

I hit a problem, I want print out a file without print first column. for example:
Code:
123  abc cde ...
234  cde def ...

I want to get as following:
Code:
abc cde ..
cde def ..

Smilie

anybody can help me out.

Thanks in advance.
ken002
# 2  
Old 09-09-2011
Is this what you are looking for?

Code:
$ cat sample7.txt
123  abc cde ...
234  cde def ...

$ cut -f3- -d" " <sample7.txt
abc cde ...
cde def ...

This User Gave Thanks to joeyg For This Post:
# 3  
Old 09-09-2011
You want to look at 'cut'
Code:
[mute@geek ~]$ cut -d' ' -f3- file
abc cde ...
cde def ...

# 4  
Old 09-09-2011
Hi, Thanks both of you. the code very close to, but I got little problem.
I have file:
Code:
39613  ORA-01400: cannot insert NULL into (AAA)
39653  ORA-01400: cannot insert NULL into (AAA)
39693  ORA-01400: cannot insert NULL into (AAA)

after I exec the code, I got
Code:
cannot insert NULL into (AAA)
cannot insert NULL into (AAA)
cannot insert NULL into (AAA)

but I want to get as following:
Code:
ORA-01400: cannot insert NULL into (AAA)
ORA-01400: cannot insert NULL into (AAA)
ORA-01400: cannot insert NULL into (AAA)

Thanks in advance
ken002
# 5  
Old 09-09-2011
try this perl code. But some how the last column "..." is not printed. I assume you dont need them.

any perl expert can correct my code. I am a beginner. thanks in advance.
Code:
while (<INPUT>) {

my ($x, $y, $z, $a) = split (/\s/);

print "$y $z $a\n";}

# 6  
Old 09-09-2011
See if this awk fills your requirement
Code:
awk ' {$1=""; print }' input

Regards
Peasant.
# 7  
Old 09-09-2011
perl is a bit much. have a look at the file, is that first " " a TAB?
-d param to cut is the delimiter, -f3- is fields 3 and more. in previous sample, you had 2 spaces before you wanted output. Now maybe you have TAB?

Code:
cut -f2-

This User Gave Thanks to neutronscott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies

2. Shell Programming and Scripting

Print the file into column

Hi All, Seeking for your assistance regarding on how to print multiple columns from file. Ex. nik.csv - input file 1,2,3,4,5,0054,May 1 11,12,13,14,15,0053,May 2 the 6th field is i converted it into decimal I create a variable on each field - pls see below. T1=`awk -F ","... (5 Replies)
Discussion started by: nikki1200
5 Replies

3. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

4. Shell Programming and Scripting

Print a column with the name of the output file

I have n files and I am using cat to combine them in to one. Before that simply add the name of the output file to 4th column and then print the output. Is it possible ? input1 chr start end name 0 + key input2 chr start end name 0 + key inputn... (1 Reply)
Discussion started by: quincyjones
1 Replies

5. Shell Programming and Scripting

print when column match with other file

Hello all, please help. There are two file like this: file1: 1197510.0 294777.7 9666973.0 21.6 1839.8 1197510.0 294777.7 9666973.0 413.2 2075.9 1197510.0 294777.7 9666973.0 689.3 2260.0 ... (1 Reply)
Discussion started by: attila
1 Replies

6. Shell Programming and Scripting

Need to find a column from one file and print certain columns in second file

Hi, I need helping in finding some of the text in one file and some columns which have same column in file 1 EG cat file_1 aaaa bbbb cccc dddd eeee fffff gggg hhhh cat file_2 aaaa,abcd,effgh,ereref,name,age,sex,........... bbbb,efdfh,erere,afdafds,name,age,sex.............. (1 Reply)
Discussion started by: jpkumar10
1 Replies

7. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

8. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

9. Shell Programming and Scripting

How do you print column 1 from comm output to a file?

Hi guys, I have a script, which after running for 20 minutes, produces a bunch of IPs. Due to a DHCP scope, some of these IPs are not useable, so I would like to eliminate them from the final list. I have used comm to do this, but am unable to extract the first column, and redirect it to a... (1 Reply)
Discussion started by: Bloke
1 Replies

10. Shell Programming and Scripting

Conditional aggregation and print of a column in file

Hi My input file looks like field1 field2 field3 field4 field5 field1 field2 field3 field4 field5 field1 field2 field3 field4 field5 :::::::::::: :::::::::::: There may be one space of multiple spaces between fields and no fields contains spaces in them. If field 1 to 4 are equal for... (3 Replies)
Discussion started by: bittoo
3 Replies
Login or Register to Ask a Question