Sponsored Content
Full Discussion: Swap of fields dynamically
Top Forums Shell Programming and Scripting Swap of fields dynamically Post 302719159 by elixir_sinari on Monday 22nd of October 2012 07:37:49 AM
Old 10-22-2012
Without any validations:
Code:
awk -F\| -v first=5 -v num=8 '{
printf "%s", $first
for(i=1;i<=num;i++)
 if(i!=first)
  printf "|%s",$i
printf "\n"
}' file

This User Gave Thanks to elixir_sinari For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Swap config - Mirror swap or not?

Hello and thanks in advance. I have a Sun box with raid 1 on the O/S disks using solaris svm. I want to unmirror my swap partition, and add the slice on the second disk as an additional swap device. This would give me twice as much swap space. I have been warned not to do this by some... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

2. UNIX for Dummies Questions & Answers

swap fields in a file

I have a file (tmp.out) with contents delimited by '|': 1|d|2|rt| 3|sfd|4|sgf| 5|sg|6|gtr| 7|s|8|sf| I want to write only the 1st and 3rd columns to another file, but they should be swapped with each other: 2|1 4|3 6|5 8|7 Here is what I have so far: ... (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

3. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

4. Red Hat

swap not defined as swap

free -m : 1023 total swap space created default partition /dev/sdb1 50M using fdisk. i did write the changes. #mkswap /dev/sdb1 #swapon /dev/sdb1 free -m : 1078 total swap space this shows that the swap is on Question : i did not change the type LINUX SWAP (82) in fdisk. so why is... (5 Replies)
Discussion started by: dplinux
5 Replies

5. HP-UX

Swap device file and swap sapce

Hi I have an integrity machine rx7620 and rx8640 running hp-ux 11.31. I'm planning to fine tune the system: - I would like to know when does the memory swap space spill over to the device swap space? - And how much % of memory swap utilization should be specified (swap space device... (6 Replies)
Discussion started by: lamoul
6 Replies

6. Programming

Dynamically added text fields passed to PHP script

If I am posting this to the wrong section please move it somewhere it fits. I apologize if this is not the correct section. I have a site where I want to have form that in a "Visitor name" section to be able to add fieldets as needed. I think I have that worked out. So the below code is the... (4 Replies)
Discussion started by: GroveTuckey
4 Replies

7. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

8. Solaris

Explain the output of swap -s and swap -l

Hi Solaris Folks :), I need to calculate the swap usage on solaris server, please let me understand the output of below swap -s and swap -l commands. $swap -s total: 1774912k bytes allocated + 240616k reserved = 2015528k used, 14542512k available $swap -l swapfile dev swaplo... (6 Replies)
Discussion started by: seenuvasan1985
6 Replies

9. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
Num(3o)                                                            OCaml library                                                           Num(3o)

NAME
Num - Operation on arbitrary-precision numbers. Module Module Num Documentation Module Num : sig end Operation on arbitrary-precision numbers. Numbers (type num ) are arbitrary-precision rational numbers, plus the special elements 1/0 (infinity) and 0/0 (undefined). type num = | Int of int | Big_int of Big_int.big_int | Ratio of Ratio.ratio The type of numbers. === Arithmetic operations === val (+/) : num -> num -> num Same as Num.add_num . val add_num : num -> num -> num Addition val minus_num : num -> num Unary negation. val (-/) : num -> num -> num Same as Num.sub_num . val sub_num : num -> num -> num Subtraction val ( */ ) : num -> num -> num Same as Num.mult_num . val mult_num : num -> num -> num Multiplication val square_num : num -> num Squaring val (//) : num -> num -> num Same as Num.div_num . val div_num : num -> num -> num Division val quo_num : num -> num -> num Euclidean division: quotient. val mod_num : num -> num -> num Euclidean division: remainder. val ( **/ ) : num -> num -> num Same as Num.power_num . val power_num : num -> num -> num Exponentiation val abs_num : num -> num Absolute value. val succ_num : num -> num succ n is n+1 val pred_num : num -> num pred n is n-1 val incr_num : num Pervasives.ref -> unit incr r is r:=!r+1 , where r is a reference to a number. val decr_num : num Pervasives.ref -> unit decr r is r:=!r-1 , where r is a reference to a number. val is_integer_num : num -> bool Test if a number is an integer === The four following functions approximate a number by an integer : === val integer_num : num -> num integer_num n returns the integer closest to n . In case of ties, rounds towards zero. val floor_num : num -> num floor_num n returns the largest integer smaller or equal to n . val round_num : num -> num round_num n returns the integer closest to n . In case of ties, rounds off zero. val ceiling_num : num -> num ceiling_num n returns the smallest integer bigger or equal to n . val sign_num : num -> int Return -1 , 0 or 1 according to the sign of the argument. === Comparisons between numbers === val (=/) : num -> num -> bool val (</) : num -> num -> bool val (>/) : num -> num -> bool val (<=/) : num -> num -> bool val (>=/) : num -> num -> bool val (<>/) : num -> num -> bool val eq_num : num -> num -> bool val lt_num : num -> num -> bool val le_num : num -> num -> bool val gt_num : num -> num -> bool val ge_num : num -> num -> bool val compare_num : num -> num -> int Return -1 , 0 or 1 if the first argument is less than, equal to, or greater than the second argument. val max_num : num -> num -> num Return the greater of the two arguments. val min_num : num -> num -> num Return the smaller of the two arguments. === Coercions with strings === val string_of_num : num -> string Convert a number to a string, using fractional notation. val approx_num_fix : int -> num -> string See Num.approx_num_exp . val approx_num_exp : int -> num -> string Approximate a number by a decimal. The first argument is the required precision. The second argument is the number to approximate. Num.approx_num_fix uses decimal notation; the first argument is the number of digits after the decimal point. approx_num_exp uses scien- tific (exponential) notation; the first argument is the number of digits in the mantissa. val num_of_string : string -> num Convert a string to a number. === Coercions between numerical types === val int_of_num : num -> int val num_of_int : int -> num val nat_of_num : num -> Nat.nat val num_of_nat : Nat.nat -> num val num_of_big_int : Big_int.big_int -> num val big_int_of_num : num -> Big_int.big_int val ratio_of_num : num -> Ratio.ratio val num_of_ratio : Ratio.ratio -> num val float_of_num : num -> float OCamldoc 2012-06-26 Num(3o)
All times are GMT -4. The time now is 11:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy