Sponsored Content
Top Forums Shell Programming and Scripting Maybe a cleaner way to generate a file? Post 303000498 by crimso on Thursday 13th of July 2017 08:12:48 AM
Old 07-13-2017
Maybe a cleaner way to generate a file?

greetings,
to be clear, i have a solution but i'm wondering if anyone has a cleaner way to accomplish the following:

the variable:
Code:
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 '

the command i used to generate the required output:
Code:
printf "%s %s\n" `echo $LSB_MCPU_HOSTS | awk '$2="15"'` | awk '{print $2, $1}' | sed "1 acp `echo ${LSB_MCPU_HOSTS} | awk '{print $1}'`"

the required output:
Code:
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

thanks in advance.
 

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
Module::Install::With(3pm)				User Contributed Perl Documentation				Module::Install::With(3pm)

NAME
Module::Install::With - find environnement for Module::Install interactive The "interactive" function tests for an install that has a user present (or at least, one in which it is reasonable for us to present prompts and other similar types of things). Returns true if in an interactive environment, or false otherwise. automated_testing Are we currently running in an automated testing environment, such as CPAN Testers. This is primarily a cleaner and more human-readable equivalent of checking $ENV{AUTOMATED_TESTING} yourself, but may be improved in line with best practices at a later date. release_testing Are we currently running in an release testing environment. That is, are we in the process of running in a potential highly-intensive and high dependency bloat testing process prior to packaging a module for release. This is primarily a cleaner and more human-readable equivalent of checking $ENV{RELEASE_TESTING} yourself, but may be improved in line with best practices at a later date. win32 The "win32" function tests if the Makefile.PL is currently running in a native Microsoft Windows Perl, such as ActivePerl or Strawberry Perl. This is primarily a cleaner and more human-readable equivalent of checking "$^O eq 'MSWin32'" yourself, but may be improved in line with best practices at a later date. winlike The "winlike" function tests if the Makefile.PL is currently running in a Microsoft Windows Perl, under either cygwin or a native Win32 Perl. This is primarily a cleaner and more human-readable equivalent of checking "$^O eq 'MSWin32' or $^O eq 'cygwin'"yourself, but may be improved in line with best practices at a later date. SEE ALSO
Module::Install AUTHORS
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2007 - 2012 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2012-03-19 Module::Install::With(3pm)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy