Sponsored Content
Top Forums Shell Programming and Scripting How to add extra spaces to make all lines the same length? Post 302940977 by vgersh99 on Friday 10th of April 2015 12:27:29 PM
Old 04-10-2015
Code:
echo '12345' | awk -v m=10 '{printf("[%-10s]\n", $0)}'
[12345     ]

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove extra spaces in a line

Hi, I need a help in deleting extra spaces in a text. I have a huge file, a part of it is :- 3 09/21/08 03:32:07 started undef mino Oracle nmx004.wwdc.numonyx.com Message Text : The Oracle session with the PID 1103 has a CPU time ... (6 Replies)
Discussion started by: vikas027
6 Replies

2. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies

3. Shell Programming and Scripting

remove extra spaces between fields

Hi, I have a source file as mentioned below: I want to remove all the extra spaces between the fields. a b--------|sa df-------|3232---|3 sf sa------|afs sdf-----|43-----|33 a b c------|adfsa dsf---|23-32|23 *Here '-' idicates spaces Now, I want output as below: a b|sa df|3232|3... (7 Replies)
Discussion started by: srilaxmi
7 Replies

4. Shell Programming and Scripting

How to remove extra spaces from a string??

Hi, I have a string like this and i want to remove extra spaces that exists between the words. Here is the sentence. $string="The small DNA genome of hepadnaviruses is replicated by reverse transcription via an RNA intermediate. This RNA "pregenome" contains ... (2 Replies)
Discussion started by: vanitham
2 Replies

5. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

6. Shell Programming and Scripting

How to add trailing spaces to have file with lines of the same length?

I have textfile (source.txt) with different length of lines in it. Can anybody help to compose a script under bash which would add suitable number of trailing spaces to the end of each line so that after the processing the each line would have the same (let's say 100 char) length? Output can be... (6 Replies)
Discussion started by: sameucho
6 Replies

7. Shell Programming and Scripting

Remove of extra spaces from the trailing

HI, I need the help from the experts like I have created one file with text like: a b c d e f g h i j k l So my question is that i have to write the script in which like in the first sentence it will take only one space after d and remove all the extra space in the end.I dont... (8 Replies)
Discussion started by: bhanudhingra
8 Replies

8. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

9. Shell Programming and Scripting

Append spaces the rows to make it into a required fixed length file

I want to make a script to read row by row and find its length. If the length is less than my required length then i hav to append spaces to that paritucular row. Each row contains special characters, spaces, etc. For example my file contains , 12345 abcdef 234 abcde 89012 abcdefgh ... (10 Replies)
Discussion started by: Amrutha24
10 Replies

10. Shell Programming and Scripting

Grep string causes extra spaces

Hello, I have an xml file and my aim is to grab each line in keywords file and search the string in another file. When keyword is found in xml file,I expect the script to go to previous line in the xml file and grab the string/value between two strings. It's almost working with an error. tab... (6 Replies)
Discussion started by: baris35
6 Replies
HASH_EQUALS(3)								 1							    HASH_EQUALS(3)

hash_equals - Timing attack safe string comparison

SYNOPSIS
bool hash_equals (string $known_string, string $user_string) DESCRIPTION
Compares two strings using the same time whether they're equal or not. This function should be used to mitigate timing attacks; for instance, when testing crypt(3) password hashes. PARAMETERS
o $known_string - The string of known length to compare against o $user_string - The user-supplied string RETURN VALUES
Returns TRUE when the two strings are equal, FALSE otherwise. ERRORS
/EXCEPTIONS Emits an E_WARNING message when either of the supplied parameters is not a string. EXAMPLES
Example #1 example <?php $expected = crypt('12345', '$2a$07$usesomesillystringforsalt$'); $correct = crypt('12345', '$2a$07$usesomesillystringforsalt$'); $incorrect = crypt('apple', '$2a$07$usesomesillystringforsalt$'); var_dump(hash_equals($expected, $correct)); var_dump(hash_equals($expected, $incorrect)); ?> The above example will output: bool(true) bool(false) NOTES
Note Both arguments must be of the same length to be compared successfully. When arguments of differing length are supplied, FALSE is returned immediately and the length of the known string may be leaked in case of a timing attack. Note It is important to provide the user-supplied string as the second parameter, rather than the first. PHP Documentation Group HASH_EQUALS(3)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy