any good idea on this?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting any good idea on this?
# 1  
Old 09-29-2006
any good idea on this?

txt file like this,

1 2 3 4456
a bb c d 3 f e
1 k 32 d m f e
123 m 2 k


every line contains 3 or more columns, all the columns are separated by space, and every column includes 1 to 3 character.

what I wanna do is deleting the first three columns, and keep the rest no matter how long the rest will be, is there a fast way to do this?
# 2  
Old 09-29-2006
try this

Code:
awk ' 
{ 
for ( i = 4 ; i < NF ; ++i ) 
        printf( "%s " , $i );
printf( "%s\n" , $NF )
}' file

# 3  
Old 09-29-2006
Hammer & Screwdriver

hmm, thank you anbu23,

I am just wondering if there is a magic method to do this....Smilie
# 4  
Old 09-29-2006
Use cut:
Code:
cut -d" " -f 4- filename

# 5  
Old 09-29-2006
you can also use cut to do this

Code:
cut -d" " -f4-

# 6  
Old 09-29-2006
MySQL

amazing!

Glenn Arndt and anbu23, you guys are really smart!

so the "-" after 4 means "to the end"? I check the manpage of cut, did not find answer for this at first glance.
# 7  
Old 09-29-2006
Yes. Similarly, you can also do -4 to get all the fields up to and including the 4th.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compact script with array - Good idea?

Hi, I have a shell script where a lot of the code is repeated. I wanted to make the code much more compact so I spoke to a guy and he suggested using arrays, like follows: #!/bin/bash readonly -a nginx=('nginx' '--prefix=/opt' '-j 4' 'http://nginx.org/download/nginx-1.2.2.tar.gz' )... (2 Replies)
Discussion started by: Spadez
2 Replies

2. Shell Programming and Scripting

need a new idea for a script

Hi all, I now have project in UNIX Solaris and I want to have some new ideas to execute it, so I hope you help me finding new ideas in scripting or some infrastructure .bye (1 Reply)
Discussion started by: hard_revenge
1 Replies

3. Solaris

Idea for project

Hi guys I need idea ti play with Solaris :cool: I have some free time and I want to learn something new, so far I learned how to install Solaris using Jumpstart and flash archives. I'm intereted in programming and networks however my programming skills are very weak so I only can learn... (3 Replies)
Discussion started by: solaris_user
3 Replies

4. UNIX for Advanced & Expert Users

echo 1 > /proc/sys/vm/drop_caches a good idea?

Hi folks. I work with several production servers, and I have seen in some Kernel Cache using most of the memory. See this pic: http://i51.tinypic.com/301nb6c.jpg Do you think this is a smart choice? Remember these are productions servers and it is extremely necesary this does not... (6 Replies)
Discussion started by: erick_tuk
6 Replies

5. Shell Programming and Scripting

help... no idea what to use

my issue now is i have a txt file containing a list like below i want to create a script that will add a constant text "Find this name" at the start and "at your directory" at the end. every line should be added by phrase at the start and end. Each line of the file should look like "Find... (4 Replies)
Discussion started by: dakid
4 Replies

6. Shell Programming and Scripting

Errors-- Any Idea

Getting some errors when i run this script.. ./xml_load_process.txt: -jar: not found ./xml_load_process.txt: syntax error at line 31 : `then' unmatched any ideas...really miffed at my inability to spot the error.... #!/bin/ksh # set -o xtrace # set environment variables export... (3 Replies)
Discussion started by: jazz21
3 Replies

7. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies

8. UNIX for Dummies Questions & Answers

Dual Boot a good idea?

I was just wondering if it would be alright to dual boot a machine with both UNIX using XTERM for the interface and windows 98 or if people consider this a bad idea? if you consider it bad do tell me some possible alternatives..also would it be better to get linux over pure unix? I'd like a visual... (8 Replies)
Discussion started by: PravusMentis
8 Replies
Login or Register to Ask a Question