Sponsored Content
Full Discussion: Organize output with awk
Top Forums Shell Programming and Scripting Organize output with awk Post 303019408 by Ophiuchus on Thursday 28th of June 2018 04:28:56 PM
Old 06-28-2018
Organize output with awk

Hello, maybe someone could help me with this.

I'm trying to print in a more ordered way this input.

the input file is:
Code:
AB   XY  UT   ZW                                      PRAT   
  0   3    4  7214800                                    93
  0   3    4  730770                                     93
         VLL  VMI  VKO  VER
          39         5

  0   1    4  7318                                       93
  0   2    4  87477                                     187
         VLL  VMI  VKO  VER
         102    7       0-0

  0   9    4  49365                                     185    
  0   1    4  5307                                       93

For some lines there are 2 related lines that contain "VLL VMI VKO VER" and in next line a corresponding value.
For example:
- The line where $4=730770 (header is ZW), has the value VLL=39 and VKO=5
- The line where $4=87477 has the value VLL=102, VMI=7 and VER=0-0

So, I would like to print this related values in the sale line when happens.

The output I'm looking for is like this:
Code:
AB   XY  UT   ZW                PRAT   VLL  VMI  VKO  VER 
  0   3    4  7214800              93
  0   3    4  730770               93   39         5
  0   1    4  7318                 93
  0   2    4  87477               187  102    7       0-0
  0   9    4  49365               185    
  0   1    4  5307                 93


I've was able to get this awk script but is far from desired output since basically is removing the lines with "VLL VMI VKO VER" and leaving the values in same place (in next line).

Code:
awk 'BEGIN{print "AB   XY  UT   ZW        PRAT    VLL  VMI  VKO  VER"}
NR>1 && $0!~"VLL" {print}
/VLL  VMI  VKO  VER/{getline v; print v}' inputfile

AB   XY  UT   ZW        PRAT    VLL  VMI  VKO  VER
  0   3    4  7214800                                    93
  0   3    4  730770                                     93
          39         5

  0   1    4  7318                                       93
  0   2    4  87477                                     187
         102    7       0-0

  0   9    4  49365                                     185
  0   1    4  5307                                       93

Thanks in advance
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I organize a series of files in date order?

I'd like to ls a group of files in date order but I'm not sure what the commands would be. Can anyone help with this? (1 Reply)
Discussion started by: hedgehog001
1 Replies

2. Shell Programming and Scripting

looking for a simple way to organize envs on our unix box...

would like to standardize how we set envs on our unix box, so I thought a menu would be a great way to accomplish this. The problem I'm experiencing, is the value is set...but ONLY during the time the menu is initiated. please see below: > /home/is/bin/r12MENU.sh ... (2 Replies)
Discussion started by: mr_manny
2 Replies

3. Shell Programming and Scripting

how organize my log file ( tabs )

hello i have written a multitask script which performs verifications on the server (RHEL 5 tikanga); based on list of rules. since the results are huge both in length and number and I am sending them all to my log file. Is there any method to organize the STATUS of my results in a defined... (1 Reply)
Discussion started by: goswami.c
1 Replies

4. Shell Programming and Scripting

Organize of Data

Hello Expert, I am new in awk. I would like to know how to arrange data like Input File: lpar1 1 2 3 4 5 6 lpar10 4 5 6 lpar3 4 5 (3 Replies)
Discussion started by: shah09
3 Replies

5. UNIX and Linux Applications

Organize (pretty) code

I'm looking for terminal programs, which organize and pretty code like HTML or JavaScript. Thanks! ---------- Post updated at 07:01 AM ---------- Previous update was at 01:49 AM ---------- Found this Online javascript beautifier (1 Reply)
Discussion started by: borobudur
1 Replies

6. Shell Programming and Scripting

need help for a script to organize data

Hey all, I have a file with info like this 12:05:44 DEV001 (15F6) 71 5 1372 131 58 100 6 0 17 DEV002 (15FA) 60 0 928 15 50 N/A 2 N/A 5 DEV003 (15FE) 77 2 961 59 51 100 1 0 2... (2 Replies)
Discussion started by: leo.maveriick
2 Replies

7. Shell Programming and Scripting

Organize file according to their extension

Hi Everyone ! i want to make an application which is written in shell script and in Bourne shell (sh) i want, when my script is executed, it read all the files in the directly and move them to folders according to their extension. suppose i have a files: test.txt test.jpg test.docx... (1 Reply)
Discussion started by: me_newbie
1 Replies

8. Shell Programming and Scripting

Discover unique names and organize

I'm attempting to write a script that will look into a directory, discover all unique names, create directories for their prefix names and place the files inside. I do this now one by one with a simple script but I'd like to automate the process. The directory would contain something like: ... (6 Replies)
Discussion started by: scribling
6 Replies

9. Shell Programming and Scripting

Is there a way to organize bash_profile across different platforms

I want to have one .bash_profile works on multiple platform, ubuntu, debian, redhat, cygwin, osx. So how should I organize .bash_profile? It can be multiple files in some subdir Let me brief you: what i want is a way to organize bash_profile across platforms so I can use one set of profiles... (2 Replies)
Discussion started by: John_Peter
2 Replies
appmgr(8)																 appmgr(8)

NAME
appmgr - Tool to manage applications and platforms SYNOPSIS
appmgr list [--no-versions] appmgr add NAME DESC [--hr=no | --hr=fine | --hr=coarse] [--beta] [--weight=NUM] [--target_nresults=NUM] appmgr delete NAME [--version=VER] [--platform=NAME] [--plan_class=NAME] appmgr update NAME [--hr=no | --hr=fine | --hr=coarse] [--beta | --no-beta] [--weight=NUM] [--target_nresults=NUM] [--user_friendly_name=DESC] [--min_version=VER] [--deprecated | --no-deprecated] appmgr update_appver NAME [--version=VER] [--platform=NAME] [--plan_class=NAME] [--deprecated | --no-deprecated] [--min_core_version=VER] [--max_core_version=VER] appmgr list_platform [--short] appmgr add_platform NAME DESC appmgr delete_platform NAME [--force] appmgr update_platform NAME [--user_friendly_name=DESC] [--deprecated | --no-deprecated] appmgr add_standard_platforms appmgr {-h | --help} DESCRIPTION
appmgr is a tool to manage platforms, applications and application versions from the command-line. Note: application refers to data in the app table; application version refers to data in the app_version table and in the file system. COMMANDS
The generic syntax is: appmgr COMMAND [command arguments] Note that command-specific options must came after the command, never before. Here is a short list of the available commands. The follow- ing sections describe the commands in detail. list List the installed applications and application versions. add Add a new application. delete Delete an application or application version. update Update the properties of an application. update_appver Update the properties of an application version. list_platform List the platforms known to the project. add_platform Add a new platform. delete_platform Delete a platform. update_platform Update the properties of a platform. add_standard_platforms Add all standard platforms to the project. LIST List the installed applications and application versions, together with any non-default properties (beta, deprecated, min. core version etc.). If the --no-versions option is specified, then the list of application versions is omitted and just the application definitions are listed. ADD Add a new application. NAME is the short name of the application as used in the file system. DESC is the user-friendly name that is dis- played to users. The following options can also be specified: --hr=no, --hr=fine, --hr=coarse Set the homogeneous redundancy class. no means all hosts are equivalent, fine means fine-grained classification of 80 classes, coarse means coarse classification of 4 classes. --beta Indicate that this is application is in beta testing. Users can select if they are willing to test applications marked as beta in their preferences; see the wiki section "Beta-test applications" about how to enable this on the web interface. --weight=NUM Specify the weight of this application if the feeder is run with the -allapps option. NUM is a floating-point value, the default is 1. --target_nresults=NUM Set the number of replicas when an otherwise unreplicated work unit is sent to a host that is not trusted. See the wiki section "Adaptive replication" for details. DELETE Delete applications or application versions. This command deletes both the database records and the files under the download and apps di- rectories, so use with care. The following options can be specified: --version=VER Select only application versions with the version number VER. The version number must be specified as major.minor. --platform=NAME Select only application versions for the platform NAME. --plan_class=NAME Select only application versions having the plan class NAME. If more than one of the options --version, --platform and --plan_class are specified, then only application versions matching all the cri- teria are deleted. If none of these options are specified, then the application is also deleted. Note that if one or more of these options are specified then the application is not deleted even if there are no more application versions remaining. UPDATE Update the properties of an application. The following properties can be modified: --hr=no, --hr=fine, --hr=coarse Set the homogeneous redundancy class. no means all hosts are equivalent, fine means fine-grained classification of 80 classes, coarse means coarse classification of 4 classes. Warning Do not change the homogeneous redundancy class while there are jobs in progress! --beta Indicate that this is application is in beta testing. Users can select if they are willing to test applications marked as beta in their preferences; see the wiki about how to enable this on the web interface. --no-beta Indicate that the application is no more in beta testing. --weight=NUM Specify the weight of this application if the feeder is run with the -allapps option. NUM is a floating-point value, the default is 1. --target_nresults=NUM Set the number of replicas when an otherwise unreplicated work unit is sent to a host that is not trusted. See the wiki article on "Adaptive replication" for details. --user_friendly_name=DESC Update the user-friendly description of the application. --min_version=VER Set the min. version of the application that the scheduler accepts. This is checked only if the client uses the anonymous platform. The version number must be specified as major.minor. --deprecated Indicate that the application is deprecated. The feeder will then ignore this application when looking for new work. --no-deprecated Remove the deprecation mark from the application. UPDATE_APPVER Update the properties of an application version. The version(s) to operate on can be specified with the --version, --platform and --plan_class options, as described at the DELETE command. The following properties can be modified: --min_core_version=VER Set the min. version of the core client that is required to run this application version. The version number must be specified as major.minor. The 3rd component (the patch level) of the core client version is ignored. --max_core_version=VER Set the max. version of the core client that is allowed to run this application. Note that the scheduler ignores this setting cur- rently. --deprecated Indicate that the application version is deprecated. The feeder will then ignore this version when looking for new work. --no-deprecated Remove the deprecation mark from the application version. LIST_PLATFORM List the platforms known to the project. If the --short option is specified, then only the short names of the platforms are listed. ADD_PLATFORM Add a new platform. NAME is the short name of the platform that is used in the scheduler requests. DESC is the user-friendly name that is displayed to users. DELETE_PLATFORM Delete a platform. If the --force option is specified, the command deletes all application versions for this platform. Otherwise, if there are such application versions, the command will fail. UPDATE_PLATFORM Update the properties of a platform. The following properties can be modified: --user_friendly_name=DESC Update the user-friendly description of the platform. --deprecated Indicate that the platform is deprecated. The feeder will then ignore this platform when looking for new work. --no-deprecated Remove the deprecation mark from the platform. ADD_STANDARD_PLATFORMS Add all the standard platform definitions to the database that do not exist yet. August 27, 2009 appmgr(8)
All times are GMT -4. The time now is 09:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy