Sponsored Content
Top Forums Shell Programming and Scripting Printing a specific number of spaces Post 302982774 by Don Cragun on Monday 3rd of October 2016 10:27:10 PM
Old 10-03-2016
Quote:
Originally Posted by SkySmart
when given a file name, im looking for the most efficient way to turn each letter of the file name into spaces.

for instance, the way im thinking of going about this is this:

Code:
MYFILE=check_disks.sh
CHANUM=$(echo ${MYFILE} | awk '{ print length }')
printf '%s\n' $CHANUM

as you can see here, i have about 3 commands that i believe can be combined into one. and im pretty sure the last printf command wouldn't work.
I must be missing the point. You show us a very inefficient script that uses two shells and an awk to print the number of characters in the value of a shell variable. I do not understand how this relates to turning each individual letter (which presumably does not include underscores and periods [and digits, but there aren't any digits in the given sample input]) into an unspecified number of <space> characters.

Please give us a clear specification of what you are trying to do, and tell us what operating system and shell you're using.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

2. Shell Programming and Scripting

delete empty spaces at specific column

Hi All, If anybody could help me with my scenario here. I have a statement file. Example of some content: DATE DESC Debit Credit Total Rate 02-Jan-08 Lodgement 200.00 1200.00 2.51 14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
Discussion started by: yonez
8 Replies

3. UNIX for Dummies Questions & Answers

grep any number of spaces

which one of the following is the correct expression to ignore line with multiple spaces after any string cat file | grep -v "xyz *$" or cat file | grep -v "xyz*$" do i need "*" to specify the sapce or " *" will do? (2 Replies)
Discussion started by: manishma71
2 Replies

4. Shell Programming and Scripting

Merge 2 columns/remove specific spaces

Hi, I have a requirement to remove certain spaces from a table of information, but I'm unsure where to start. A typical table will be like this: ABCDE 1 Elton John 25 12 15 9 3 ABCDE 2 Oasis 29 13 4 6 9 ABCDE 3 The Rolling Stones 55 19 3 8 6The goal is to remove only the spaces between... (11 Replies)
Discussion started by: danhodges99
11 Replies

5. Shell Programming and Scripting

determine the number of spaces

Here is a weird question :) i am trying to create a script written in bash that will create configuration files for nagios. As some of you aware is has to be written in the below format: define service{ option1 value1 option2 value2... (6 Replies)
Discussion started by: ppolianidis
6 Replies

6. Shell Programming and Scripting

Replace spaces at a specific Location

Hello All, I have a comma separated file which needs to be loaded to the database. But, I need to trim the white spaces for a specific column before its loaded. Below is the sample line from the input file: 690,690,0575,"01011940","01011940", , , , , ,36720,36722,V2020,V2999,... (6 Replies)
Discussion started by: Praveenkulkarni
6 Replies

7. Shell Programming and Scripting

Printing Number of Fields with the line number

Hi, How to print the number of fields in each record with the line number? Lets saw I have 3212|shipped|received| 3213|shipped|undelivered| 3214|shipped|received|delivered I tried the code awk -F '|' '{print NF}' This gives me ouput as 3 3 4 (5 Replies)
Discussion started by: machomaddy
5 Replies

8. Shell Programming and Scripting

print - for printing whole line, but delimeters are changed to spaces

Hi consider the source file R|field1|field2 using the print statement in awk prints it as R field1 field2 Is there an easier way to print the whole line in its original format (i.e. with | delimiters) than doing print $1"|"$2"|"$3 ?? Thanks Storms (1 Reply)
Discussion started by: Storms
1 Replies

9. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

10. Shell Programming and Scripting

Print a specific number of spaces

i'm looking for a command that allows me to print a specific number of spaces which i will provide. something as simple as: spaces=4 printf " " * $spaces i'm looking for somethign that'll allow me to print a specific amount of spaces on a line. can awk be used for this? (4 Replies)
Discussion started by: SkySmart
4 Replies
PMDAINSTANCE(3) 					     Library Functions Manual						   PMDAINSTANCE(3)

NAME
pmdaInstance - return instance descriptions for a PMDA C SYNOPSIS
#include <pcp/pmapi.h> #include <pcp/impl.h> #include <pcp/pmda.h> int pmdaInstance(pmInDom indom, int inst, char *name, __pmInResult **result, pmdaExt *pmda); cc ... -lpcp_pmda -lpcp DESCRIPTION
pmdaInstance uses the standard PMDA(3) data structures to return information concerning the instance domain indom. The result structure is constructed by pmdaInstance and will contain one or more instance names and/or identifiers as specified by the inst and name arguments. If inst has the value PM_IN_NULL and name is a null string, result will contain all the instances names and identifiers in the instance do- main. If inst is PM_IN_NULL but name is the name of an instance in the instance domain indom, then result will contain the instance identifier for instance name. Note that if name contains no spaces, partial matching up to the first space in the instance name is performed, i.e. ``1'' will match instance name ``1 minute''. If name contains an embedded space, then no partial matching is performed and name should match one of the instance names exactly. If name is a null string but inst is an instance identifier in the instance domain indom, then result will contain the name for instance inst. The result structure is allocated with malloc(3) and should be released by the caller with free(3). DIAGNOSTICS
If any errors occur during the execution of pmdaInstance, the result structure is deallocated. If the instance domain indom is not sup- ported by the PMDA, pmdaInstance will return PM_ERR_INDOM. If the inst or name does not correspond to any instances in the indom domain, pmdaInstance will return PM_ERR_INST. CAVEAT
The PMDA must be using PMDA_INTERFACE_2 or later, as specified in the call to pmdaDSO(3) or pmdaDaemon(3). Because of optional partial matching up to the first space in the instance name, the PMDA developer should ensure that if instance names are allowed to have spaces, the names are unique up to the first space. SEE ALSO
malloc(3), PMAPI(3), PMDA(3) and pmGetInDom(3). Performance Co-Pilot PCP PMDAINSTANCE(3)
All times are GMT -4. The time now is 09:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy