Sponsored Content
Top Forums Shell Programming and Scripting Scripting Issue with Variables from awk Post 302818889 by juzz4fun on Sunday 9th of June 2013 07:27:37 PM
Old 06-09-2013
Try for loop instead...see if this works for you


Code:
#!/bin/bash
for i in 100 101 102
do
  v1=`cat sort | awk -v va=$i ' $0~"^"va ' | cut -d, -f2`
  v2=`cat sort | awk -v va=$i ' $0~"^"va ' | cut -d, -f3`
  v3=`cat sort | awk -v va=$i ' $0~"^"va ' | cut -d, -f4`
  v4=`cat sort | awk -v va=$i ' $0~"^"va ' | cut -d, -f5`
  v5=`cat sort | awk -v va=$i ' $0~"^"va ' | cut -d, -f6`

echo $i > $i.php
echo $v1 >> $1.php
echo $v2 >> $1.php
echo $v3 >> $1.php
echo $v4 >> $1.php
echo $v5 >> $1.php

done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk scripting issue

Ok, after pulling my hair out on this one, i need to ask for some help I have a file called "final" that looks like the following (this is a section of a bigger file) 18-5-252906,180105,00041.00,42070461139120,AUTH CODE:630911,000,101 18-5-255398,170105,01594.00,42110524389101,AUTH... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

2. UNIX for Dummies Questions & Answers

server variables in bash scripting

are they any server variables in bash/SSH scripting as is in PHP or Perl, for example in PHP: $_SERVER or $_SERVER I'm trying to retrieve the absolute path of an .SH script I'm running thank you (6 Replies)
Discussion started by: basher400
6 Replies

3. Shell Programming and Scripting

exporting variables (shell scripting)

Hi, i've got an executable shell script, called mysc.sh with this line only: export DATASIZE=0 i run it from my console (./mysc.sh), and after that in the console i run: echo $DATASIZE and nothing prints what could be the problem??? thanks!! (2 Replies)
Discussion started by: kfad
2 Replies

4. Shell Programming and Scripting

scripting headache... loops & variables

Surely there's an easier way to do this, lets see if anyone knows! I am new to scripting so go easy on me! I have the following script and at the moment it doesn't work and I believe the problem is that I am using a while loop within a while loop. When I run the script using sh -x I can see... (6 Replies)
Discussion started by: StevePace
6 Replies

5. Shell Programming and Scripting

awk scripting issue

hi guys, I am quite a newbie to Linux.I have an issue.Please help me; I have to create a script that runs "ls -la" inside a directory Bong and then I need to run the command through awk and have the output as follows: Filename: abc.txt Owner: test1 Group: test2 Permissions:... (1 Reply)
Discussion started by: mahesh_raghu
1 Replies

6. Shell Programming and Scripting

beginner scripting questions User variables

If there's anywhere to look this up, it would be just as helpful. I googled and really couldn't find anything relative to this. ok... General Variables 1) When creating a script I made a file "prog1.sh" does it matter if the end is .sh or is this what has to be done like prog.bash or... (4 Replies)
Discussion started by: austing5
4 Replies

7. Shell Programming and Scripting

Awk script problem - Variables Causing Issue

can someone please explain to me what i'm doing wrong with this code: WELT=$(awk '(($1 ~ "^${caag}$") || ($2 ~ "^${caag}$"))' /tmp/Compare.TEXT) when run from the command line, it works. but it seems to be having a problem doing the comparison when variables are involved. i tested from... (1 Reply)
Discussion started by: SkySmart
1 Replies

8. Shell Programming and Scripting

awk issue expanding variables in ksh script

Hi Guys, I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need. I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles. ... (3 Replies)
Discussion started by: gazza-o
3 Replies

9. Shell Programming and Scripting

Create, validate and using dynamic variables in Bash scripting

Hi All, I am really struggling to solve this problem, this might be small but I am not able to, can somebody help me? I have few directories and these directories receives text files in large amount with in fraction of seconds. So I just want to send all the files in current directory to... (2 Replies)
Discussion started by: VasuKukkapalli
2 Replies

10. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies
MSSQL_NUM_FIELDS(3)													       MSSQL_NUM_FIELDS(3)

mssql_num_fields - Gets the number of fields in result

SYNOPSIS
int mssql_num_fields (resource $result) DESCRIPTION
mssql_num_fields(3) returns the number of fields in a result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). RETURN VALUES
Returns the number of fields, as an integer. EXAMPLES
Example #1 mssql_num_fields(3) example <?php // Connect to MSSQL and select the database $link = mssql_connect('KALLESPCSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php', $link); // Select some data from our database $data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); // Construct a table echo '<table border="1">'; $header = false; // Iterate through returned results while ($row = mssql_fetch_array($data)) { // Build the table header if (!$header) { echo '<thead>'; echo '<tr>'; for ($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) { echo '<td>' . ucfirst($row[$i]) . '</td>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; $header = true; } // Build the row echo '<tr>'; foreach($row as $value) { echo '<td>' . $value . '</td>'; } echo '</tr>'; } // Close table echo '</tbody>'; echo '</table>'; // Clean up mssql_free_result($data); mssql_close($link); ?> SEE ALSO
mssql_query(3), mssql_fetch_field(3), mssql_num_rows(3). PHP Documentation Group MSSQL_NUM_FIELDS(3)
All times are GMT -4. The time now is 01:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy