Sponsored Content
Top Forums Shell Programming and Scripting Parse hdiutil -plist data for specific info Post 302625395 by Chubler_XL on Tuesday 17th of April 2012 05:14:54 PM
Old 04-17-2012
Try this (Array DMGSIZE will contain size of each .dmg file in DMGLIST):

Code:
#!/bin/bash
#first part of script which generates the array below
pos=0
for i in ${DMGLIST[@]} #This array contains a list of .dmg files
do
    DMGSIZE[pos++]=$(hdiutil imageinfo -plist $1 | awk -F"[<>]" 'a{print $3; exit}$2=="key"&&$3=="Total Bytes"{a=1}')
done

Though it may be better to generate DMGSIZE at the same time you are generating DMGLIST, ie in the bit of the script not shown.
This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Extracting specific info from finger command

Hello all, my unix is bash based and the finger command output is: Login Name Tty Idle LoginTime Office amos.john Amos John pts/26 1 Dec 5 16:18 (77.100.22.07) What am trying to achieve is extract the Login (amos.john) and Name (Amos John) from this output without using awk or sed. ... (1 Reply)
Discussion started by: franny
1 Replies

2. Shell Programming and Scripting

how to retrieve required specific info from the file

Hi I have a file which consists of a number in the square brackets, followed by the blank line, then several lines which describe this number. This pattern is repeated several thousands time. The number in the brackets and the decription of it is unique. For example: ASRVSERV=1241GD;... (2 Replies)
Discussion started by: aoussenko
2 Replies

3. Shell Programming and Scripting

how do i parse by specific column?

I have a log file with 13 columns. The 12th column contains the status code (example 200, 404, 500, 403, etc.) I want to remove all 200 status lines. so... 1. remove all the lines in which the 12th column has a 200. 2. display only the lines in which the 12th column shows a 500. ... (2 Replies)
Discussion started by: kmaq7621
2 Replies

4. UNIX for Dummies Questions & Answers

How to parse the specific data from the file

Hi, I need to parse this data FastEthernet0/9,|FastEthernet0/10,|FastEthernet0/11,FastEthernet0/13|, FastEthernet0/12,FastEthernet0/24 . and get only the value like e.g 0/24,0/11. how to do this in shell script. Thanks in Advance. (2 Replies)
Discussion started by: MuthuAlagappan
2 Replies

5. Shell Programming and Scripting

Parse a String for a Specific Word

Hello, I'm almost there with scripting, and I've looked at a few examples that could help me out here. But I'm still at a lost where to start. I'm looking to parse each line in the log file below and save the output like below. Log File AABBCGCAT022|242|3 AABBCGCAT023|243|4... (6 Replies)
Discussion started by: ravzter
6 Replies

6. Shell Programming and Scripting

Parse out specific lines

Hello, For the life of me, I can't figure out how to extract only certain lines of a file. For example, the file contains: project.max-sem-ids privileged 1.02K - deny - system 16.8M max deny ... (2 Replies)
Discussion started by: PointyWombat
2 Replies

7. UNIX for Dummies Questions & Answers

Extracting specific info finger command

how to extract user machine name for current terminal using finger command below command gives machinename for all session , is it possible to filter it to only currernt terminal ? finger -b -p $LOGNAME | grep from (12 Replies)
Discussion started by: lalitpct
12 Replies

8. Shell Programming and Scripting

Parse and display specific columns

Hi.. I am in help of displaying this specific case. I have multiple files where i have to display accordingly. Input file ##INFO1 ##INFO2 ##INFO3 #CHROM POS INFO 57.sorted.bam 58.sorted.bam 59.sorted.bam 34.sorted.bam 55.sorted.bam... (12 Replies)
Discussion started by: empyrean
12 Replies

9. UNIX for Advanced & Expert Users

os x hdiutil expert needed

I am writing a script that using the "Total Bytes" field from hdiutil imageinfo -plist <file>. My intention is to get the total mounted size of a compressed dmg. It works for some images, but sometimes it doesn't seem to match up, particularly with larger (over 1 gb) images. Can anybody explain... (10 Replies)
Discussion started by: nextyoyoma
10 Replies

10. Shell Programming and Scripting

Parse text file using specific tags

awk -F "" '/<href=>|<href=>|<top>|<top>/ {print $3, OFS=\t}' source.txt > output.txt I'm not quite sure how to parse the attached file, but what I am trying to do is in a output file have the link (href=), name (after the <), and count (<top>) in 3 separate columns. My attempt is the above... (2 Replies)
Discussion started by: cmccabe
2 Replies
Slurm::Bitstr(3pm)					User Contributed Perl Documentation					Slurm::Bitstr(3pm)

NAME
Slurm::Bitstr - Bitstring functions in libslurm SYNOPSIS
use Slurm; $bitmap = Slurm::Bitstr::alloc(32); if ($bitmap->test(10)) { print "bit 10 is set "; } DESCRIPTION
The Slurm::Bitstr class is a wrapper of the bit string functions in libslurm. This package is loaded and bootstrapped with package Slurm. METHODS
$bitmap = Slurm::Bitstr::alloc($nbits); Allocate a bitstring object with $nbits bits. An opaque bitstr object is returned. This is a CLASS METHOD. $bitmap->realloc($nbits); Reallocate a bitstring(expand or contract size). $nbits is the number of bits in the new bitstring. $len = $bitmap->size(); Return the number of possible bits in a bitstring. $cond = $bitmap->test($n); Check if bit $n of $bitmap is set. $bitmap->set($n); Set bit $n of $bitmap. $bitmap->clear($n); Clear bit $n of $bitmap. $bitmap->nset($start, $stop); Set bits $start .. $stop in $bitmap. $bitmap->nclear($start, $stop); Clear bits $start .. $stop in $bitmap. $pos = $bitmap->ffc(); Find first bit clear in $bitmap. $pos = $bitmap->nffc($n) Find the first $n contiguous bits clear in $bitmap. $pos = $bitmap->noc($n, $seed); Find $n contiguous bits clear in $bitmap starting at offset $seed. $pos = $bitmap->nffs($n); Find the first $n contiguous bits set in $bitmap. $pos = $bitmap->ffs(); Find first bit set in $bitmap; $pos = $bitmap->fls(); Find last bit set in $bitmap; $bitmap->fill_gaps(); Set all bits of $bitmap between the first and last bits set(i.e. fill in the gaps to make set bits contiguous). $cond = $bitmap1->super_set($bitmap2); Return 1 if all bits set in $bitmap1 are also set in $bitmap2, 0 otherwise. $cond = $bitmap1->equal($bitmap2); Return 1 if $bitmap1 and $bitmap2 are identical, 0 otherwise. $bitmap1->and($bitmap2); $bitmap1 &= $bitmap2. $bitmap->not(); $bitmap = ~$bitmap. $bitmap1->or($bitmap2); $bitmap1 |= $bitmap2. $new = $bitmap->copy(); Return a copy of the supplied bitmap. $dest_bitmap->copybits($src_bitmap); Copy all bits of $src_bitmap to $dest_bitmap. $n = $bitmap->set_count(); Count the number of bits set in bitstring. $n = $bitmap1->overlap($bitmap2); Return number of bits set in $bitmap1 that are also set in $bitmap2, 0 if no overlap. $n = $bitmap->clear_count(); Count the number of bits clear in bitstring. $n = $bitmap->nset_max_count(); Return the count of the largest number of contiguous bits set in $bitmap. $sum = $bitmap->inst_and_set_count($int_array); And $int_array and $bitmap and sum the elements corresponding to set entries in $bitmap. $new = $bitmap->rotate_copy($n, $nbits); Return a copy of $bitmap rotated by $n bits. Number of bit in the new bitmap is $nbits. $bitmap->rotate($n); Rotate $bitmap by $n bits. $new = $bitmap->pick_cnt($nbits); Build a bitmap containing the first $nbits of $bitmap which are set. $str = $bitmap->fmt(); Convert $bitmap to range string format, e.g. 0-5,42 $rc = $bitmap->unfmt($str); Convert range string format to bitmap. $array = Slurm::Bitstr::bitfmt2int($str); Convert $str describing bitmap (output from fmt(), e.g. "0-30,45,50-60") into an array of integer (start/edn) pairs terminated by -1 (e.g. "0, 30, 45, 45, 50, 60, -1"). $str = $bitmap->fmt_hexmask(); Given a bit string, allocate and return a string in the form of: "0x0123ABC" ^ ^ | | MSB LSB $rc = $bitmap->unfmt_hexmask($str); Give a hex mask string "0x0123ABC", convert to a bit string. ^ ^ | | MSB LSB $str = $bitmap->fmt_binmask(); Given a bit string, allocate and return a binary string in the form of: "0001010" ^ ^ | | MSB LSB $rc = $bitmap->unfmt_binmask($str); Give a bin mask string "0001010", convert to a bit string. ^ ^ | | MSB LSB $pos = $bitmap->get_bit_num($n); Find position of the $n-th set bit(0 based, i.e., the first set bit is the 0-th) in $bitmap. Returns -1 if there are less than $n bits set. $n = $bitmap->get_pos_num($pos); Find the number of bits set minus one in $bitmap between bit postion [0 .. $pos]. Returns -1 if no bits are set between [0 .. $pos]. SEE ALSO
Slurm AUTHOR
This library is created by Hongjia Cao, <hjcao(AT)nudt.edu.cn> and Danny Auble, <da(AT)llnl.gov>. It is distributed with SLURM. COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-03-16 Slurm::Bitstr(3pm)
All times are GMT -4. The time now is 05:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy