how to AWK columns from $1 to $5 without $2 $3 $4

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to AWK columns from $1 to $5 without $2 $3 $4
# 1  
Old 10-04-2009
how to AWK columns from $1 to $5 without $2 $3 $4

cant find a way to make something like:
awk '{print $1 - $5}' somefile
which is printing $1 $2 $3 $4 $5

should make an array or something? i just dont wanna write $1 $2 $3 $4 $5 to awk input i need to use from $1 to $5 and print them all

and then i need to swith to: from $6 to $10
# 2  
Old 10-04-2009
use for loop.

nawk '
for (i=begin;i<=end;i++) {
print $i

'  input_file > output_file

note:- you can change the variable "begin,end" as you want.

Best Regards
# 3  
Old 10-06-2009
cut -f1-5 urfile
cut -f6-10 urfile

# 4  
Old 10-06-2009
atm it's working like this:

until [ $j -gt $totalwords ]; do
j2=$(($j + 4))
echo -n "$(sed -n ${i}p $curfile |cut -d" " -f$j-$j2)" >>${curfile}_2
echo -n " $(sed -n $(($RANDOM % $totalines2 +1))p keys) " >>${curfile}_2
j=$(($j2 + 1))

it does inserting of a string from fileB to every 5 words in a string of fileA
thing is.. working it too slow so thats why i'm tryed to make it on awk
but atm i started to learn perl cuz there all that things can be found very effective
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies

2. Shell Programming and Scripting

Rearranging into new columns (awk?)

Hi experts, I've used several solutions from this forum to delete nonsense and rearrange data in the project file I'm working on. I'm hoping you guys can give me some tips on further rearranging the data (I've seen a few solutions by searching, but one specific item has me stumped, which is only... (5 Replies)
Discussion started by: coryvp
5 Replies

3. Shell Programming and Scripting

Removing columns using awk

HI , I have a comma delimiter file, in which I want to remove 8th and 9th column. I tried removing those columns using the below code awk 'BEGIN { FS=","; OFS="," } {$8=$9="";gsub(",+",",",$0)}1' infile But the problem is 8th and 9th columns are user entered fields, theyvhave carriage... (1 Reply)
Discussion started by: mora
1 Replies

4. Shell Programming and Scripting

awk some columns from file

I have a file that has a list in this format: abcdefg|||||PROV|ADTHNION21E|USA|DLAR|CISCO||OS| abcdefg|||||PROV|ADTHNION22E|USA|DLAR|CISCO||OS| I need to pull the red highlighed fileds so the output looks... (2 Replies)
Discussion started by: numele
2 Replies

5. Shell Programming and Scripting

Transposing columns with awk

I want a sweet simple time efficient awk script in online which gets output 001_r 0.0265185 0.0437049 0.0240642 0.0310264 0.0200482 0.0146746 0.0351344 0.0347856 0.036119 1.49 firstcoloumnvalue allvaluesof 'c' in one row 001_r : 002_r c: 0.0265185 N: 548 001_r : 007_r c:... (5 Replies)
Discussion started by: phoenix_nebula
5 Replies

6. UNIX for Advanced & Expert Users

Using awk : picking specified columns

Hi, I would like to get some specific fields from one long line. My line looks like CcnCDRFile0-8535123473201007170536_2010-07-20_17:06:02:,,9963387265,,,,,00720141432,,+0.310,+79.255,+78.945,,,,1492,,,,0,... (1 Reply)
Discussion started by: kkarthik_kaja
1 Replies

7. Shell Programming and Scripting

Awk - New Line between columns

I have a data file with 4 columns, of the format: A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 etc.. I would like to insert to put column 2,3,4 on a new line so my new format would be: A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 etc. but am new at using AWK and am not sure how to do it. (5 Replies)
Discussion started by: mikeyd
5 Replies

8. Shell Programming and Scripting

awk sum columns

can anyone help me how do i add the colums using awk seperated by character @. for eg i have 3@4 2@9 5@1 the result should be 10 14 i tried using { sum+= $1 } END { print sum } but it just gives the result 10. can anyone help me with this one thank you and best regards (7 Replies)
Discussion started by: phone_book
7 Replies

9. Shell Programming and Scripting

List to columns and awk help

Hi I'm new to this forum and I'm a beginner when it comes to shell programming and awk programming. But I have the following problem: I've a list like this: 1 2 3 4 5 6 7 8 Either from a file or output from a command. What I would like to do is to arrange these values into x columns... (17 Replies)
Discussion started by: baghera
17 Replies

10. Shell Programming and Scripting

add columns with awk

hi everybody: My question is how could i add a new columns to a file that it has one column like this: 06/06/2005 06/07/2005 06/08/2005 06/09/2005 06/10/2005 06/11/2005 06/12/2005 06/13/2005 06/14/2005 06/15/2005 06/16/2005 06/17/2005 .... And i want add columns like : 06/06/2005 ... (4 Replies)
Discussion started by: tonet
4 Replies
Login or Register to Ask a Question