Sponsored Content
Top Forums Shell Programming and Scripting Maybe a cleaner way to generate a file? Post 303000506 by durden_tyler on Thursday 13th of July 2017 11:08:16 AM
Old 07-13-2017
Here's my attempt.
I would avoid all those pipelines and try to do all transformations in awk or sed or Perl etc.

Code:
$
$ echo $LSB_MCPU_HOSTS
t70c7n120 16 t70c7n121 16 t70c7n122 16 t70c7n123 16 t70c7n124 16 t70c7n125 16 t70c7n126 16 t70c7n127 16 t70c7n128 16 t70c7n129 16 t70c7n130 16 t70c7n131 16 t70c7n132 16 t70c7n117 16 t70c7n118 16 t70c7n119 16
$
$ echo $LSB_MCPU_HOSTS | awk '{ $2 = "15";
                                for(i=1; i<=NF; i+=2) {
                                    n = i+1;
                                    print $n, $i;
                                    if (i == 1){print "cp", $1}
                                }
                              }'
15 t70c7n120
cp t70c7n120
16 t70c7n121
16 t70c7n122
16 t70c7n123
16 t70c7n124
16 t70c7n125
16 t70c7n126
16 t70c7n127
16 t70c7n128
16 t70c7n129
16 t70c7n130
16 t70c7n131
16 t70c7n132
16 t70c7n117
16 t70c7n118
16 t70c7n119
$
$


Last edited by durden_tyler; 07-13-2017 at 12:13 PM..
This User Gave Thanks to durden_tyler For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl : how to modify a file without generate a temporary file

Hi All, I have a file like below, how can i insert one line after line 1 without using a temporary file in perl? line 1 line 2 line 3 expected result line 1 new line <---insert here line 2 line 3 (2 Replies)
Discussion started by: summer_cherry
2 Replies

2. Programming

How to simplify this perl script to a cleaner simpler look?

my $branch_email_e = $FORM{r_Branch}; my $hostbranch_email_e = $FORM{r_Host_Branch}; my $branch_email_f = $FORM{r_Direction_generale}; my $hostbranch_email_f = $FORM{r_Direction_generale_daccueil}; my $branch_realname_e = ''; my $branch_realname_f = ''; ... (4 Replies)
Discussion started by: callyvan
4 Replies

3. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

4. Shell Programming and Scripting

Grabbing the newest file, cleaner method?

Greetings, I'm doing a process whereby I need to search for all filenames containing a given bit of text and grab the newest file from what may be 20 results. In a script I'm writing, i've got a monster line to do the sort as follows: find /opt/work/reports/input -name "*$searchtarget*" |... (4 Replies)
Discussion started by: Karunamon
4 Replies

5. Shell Programming and Scripting

Cleaner method for this if-then statement?

I have a script that runs once per month. It performs a certain task ONLY if the month is January, April, July, or October. MONTH=`date +%m` if || || || ; then do something else do a different thing fi Is there a neater way of doing it than my four separate "or" comparisons? That... (2 Replies)
Discussion started by: lupin..the..3rd
2 Replies

6. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

7. Shell Programming and Scripting

Cleaner way to use shell variable in awk /X/,/Y/ syntax?

$ cat data Do NOT print me START_MARKER Print Me END_MARKER Do NOT print me $ cat awk.sh start=START_MARKER end=END_MARKER echo; echo Is this ugly syntax the only way? awk '/'"$start"'/,/'"$end"'/ { print }' data echo; echo Is there some modification of this that would work? awk... (2 Replies)
Discussion started by: hanson44
2 Replies

8. Shell Programming and Scripting

A cleaner way to rearrange column

Hello, I have some tab delimited text data, index name chg_p chg_m 1 name,1 1 0 2 name,2 1 1 3 name,3 1 0 4 name,4 1 0 5 name,5 1 1 I need to duplicate the "index" column, call it "id" and insert it after the... (8 Replies)
Discussion started by: LMHmedchem
8 Replies

9. War Stories

Data Centre meets Vacuum Cleaner

Hi Folks, I have just spent a couple of days resolving some problems at the remote DR data centre, sorting out the problems caused by the over zealous use of a Vacuum cleaner of all things. We have a backup server a SUN V480R with a Storedge 3510 and expansion attached which suffered a... (6 Replies)
Discussion started by: gull04
6 Replies
ttk::frame(n)							 Tk Themed Widget						     ttk::frame(n)

__________________________________________________________________________________________________________________________________________________

NAME
ttk::frame - Simple container widget SYNOPSIS
ttk::frame pathName ?options? _________________________________________________________________ DESCRIPTION
A ttk::frame widget is a container, used to group other widgets together. STANDARD OPTIONS
-class -cursor -takefocus -style See the ttk_widget manual entry for details on the standard options. WIDGET-SPECIFIC OPTIONS [-borderwidth borderWidth] The desired width of the widget border. Defaults to 0. [-relief relief] One of the standard Tk border styles: flat, groove, raised, ridge, solid, or sunken. Defaults to flat. [-padding padding] Additional padding to include inside the border. [-width width] If specified, the widget's requested width in pixels. [-height height] If specified, the widget's requested height in pix- els. WIDGET COMMAND
Supports the standard widget commands configure, cget, identify, instate, and state; see ttk::widget(n). NOTES
Note that if the pack, grid, or other geometry managers are used to manage the children of the frame, by the GM's requested size will nor- mally take precedence over the frame widget's -width and -height options. pack propagate and grid propagate can be used to change this. SEE ALSO
ttk::widget(n), ttk::labelframe(n), frame(n) KEYWORDS
widget, frame, container Tk 8.5 ttk::frame(n)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy