Sponsored Content
Top Forums Shell Programming and Scripting parse a file and fill an array with it Post 302192623 by jbmukund on Wednesday 7th of May 2008 12:51:52 PM
Old 05-07-2008
RE: parse a file and fill an array with it

Hi Franklin,

Thanks you, I got it working.
But, I want these details in a array with extra spaces removed.

However, I tried by adding a ssh command to it and does not work
When I do this the loop gets restricted to a single iteration. ?I did not see the second iteration happening. and it happens only the case of ssh.

Instead local commands works fine.

awk '{for(i=2;i<=NF;i++){print $i}}' "a" |
while read mach; do
#do your stuff here
echo "hello $mach"
ssh root@rna4 uname -n # <----
echo $?
done

Regards,
Mukund Jampala


Quote:
Originally Posted by Franklin52
Like Annihilannic mentioned, I had a typo in the code, and the loop begins with the second field after the "=" so I assume this is the first machine name. Maybe it should begins with the 3th field, try it out.

Code:
awk '{for(i=2;i<=NF;i++){print $i}}' "config.file" |
while read mach; do
  #do your stuff here
  echo "$mach"
done

Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Read directory and fill a file with this information

Hello All, Got a question to make a script what reads a directory and put the file names from that directory in a file with some extra text. ls /tempdir output is: file1.gfh file2.txt file4.zzz these file names (always with an extention) must be placed in a line and written to... (2 Replies)
Discussion started by: ToXiQ
2 Replies

2. Shell Programming and Scripting

Need to parse file "x" lines at a time ... awk array?

I have files that store multiple data points for the same device "vertically" and include multiple devices. It repeats a consistant pattern of lines where for each line: Column 1 is a common number for the entire file and all devices in that file Column 2 is a unique device number Column 3 is... (7 Replies)
Discussion started by: STN
7 Replies

3. Shell Programming and Scripting

How to fill data from other file and get some output

Greetings, I have a hard time creating a large number of user profiles in a database. The data file looks like this : 01/01/80 Mitch Conley . . . . And I need to put the output into: Name: Mitch Surname: Conley Birthday: 01/01/80 Thanks in advance! (3 Replies)
Discussion started by: hemo21
3 Replies

4. UNIX for Dummies Questions & Answers

Fill fields with awk from an array?

Hi experts, I have been trying for a while to accomplish the following task using awk, and I just don't seem find find a way. I am not particular about using awk, it just seemed like the logical choice at first. I have a file that contains 5 fields that are delimited by a space character.... (1 Reply)
Discussion started by: GermanicGalore
1 Replies

5. Shell Programming and Scripting

Script which fill data in XML file

Hello, I need help for writing a script that fills already generated xml file with data from oracle database and random sequences. For example if we have the following tags: <ns1:message> <ns1:messageId> </ns1:messageId> <ns1:languageCode> </ns1:languageCode>... (10 Replies)
Discussion started by: zb99
10 Replies

6. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

7. Shell Programming and Scripting

Parse find input into array

I need help parsing the output of find into an array. I need to search 3 directories and find all files older than 31 days old. This is what I have so far. TIME=" -maxdepth 1 -mtime +31" DIR1="/dir1/" DIR2="/dir2/" DIR3="/dir3/" FIND_DIR1=$(find ${DIR1}${TIME}) FIND_DIR3=$(find... (8 Replies)
Discussion started by: jrymer
8 Replies

8. UNIX for Dummies Questions & Answers

Fill csv entire column with content from another text file

I have a csv that looks like this: ,yude-to-nap2,0,0,0,0,0 ,2twis-yude-to-nap2,0,0,0,0,0 ,2tiws-yude-to-nap2,0,0,0,0,0 ,2arcos-yude-to-nap2,0,0,0,0,0 and another file named m1 that has a single line of text as content: Feb 1 15:30:20 How can I fill the whole the empty column of the... (1 Reply)
Discussion started by: RobertoRivera
1 Replies

9. Shell Programming and Scripting

Perl script to fill the entire row of Excel file with color based on pattern match

Hi All , I have to write one Perl script in which I need to read one pre-existing xls and based on pattern match for one word in some cells of the XLS , I need to fill the entire row with one color of that matched cell and write the content to another excel Please find the below stated... (2 Replies)
Discussion started by: kshitij
2 Replies

10. Shell Programming and Scripting

awk to parse section of csv into array

In the awk below I am trying to parse the Sample Name below the section. The values that are extracted are read into array s(each value in a row seperated by a space) which will be used later in a bash script. The awk does execute but no values are printed. I am also not sure how to print in a row... (1 Reply)
Discussion started by: cmccabe
1 Replies
cs_parse_file(3)						      cs/cs.h							  cs_parse_file(3)

NAME
cs_parse_file - parse a CS template file SYNOPSIS
#include <cs/cs.h> NEOERR *cs_parse_file (CSPARSE *parse, const char *path); ARGUMENTS
parse - a CSPARSE structure created with cs_init path - the path to the file to parse DESCRIPTION
cs_parse_file will parse the CS template located at path. It will use hdf_search_path() if path does not begin with a '/'. The parsed CS template will be appended to the current parse tree stored in the CSPARSE structure. The entire file is loaded into memory and parsed in place. RETURN VALUE
None SEE ALSO
cs_dump(3), cs_destroy(3), cs_render(3), cs_register_esc_strfunc(3), cs_arg_parsev(3), cs_register_fileload(3), cs_init(3), cs_regis- ter_strfunc(3), cs_arg_parse(3), cs_parse_string(3), cs_parse_file(3), =(3), cs_register_function ClearSilver 12 July 2007 cs_parse_file(3)
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy