Multiple lines of data?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Multiple lines of data?
# 1  
Old 04-27-2019
Multiple lines of data?

I use this to get 8 random letters:

Code:
cat /dev/urandom | tr -dc 'A-Z' | fold -w 8 | head -n 1

Result is,
WLGFJFZY

What I'm trying to do is get 10 lines of random letters, separated by a line and each block having ascending numbers
i.e;

00
IWMTDFIM

01
KZZZCHPQ

02
YBTGFHGT

03
OAOXSDMR

etc, etc..

(Thanks).
# 2  
Old 04-27-2019
Code:
$ cat /dev/urandom | tr -dc 'A-Z' | fold -w 8 | awk ' { if(NR < 11) { printf("%02d\n%s\n\n",NR,$0) } else { exit} } '
01
STUVMDHN

02
IHLVHDGD

03
RDZMKZVS

04
MLPNBHCD

05
QWCPAZRD

06
SLYHEVSE

07
GESUXXOO

08
FXMABYFF

09
GKKTGYJH

10
IRIPGRXY

This User Gave Thanks to anbu23 For This Post:
# 3  
Old 04-27-2019
Thanks. Another question: what part of the code can I alter to make more than 10 lines? Say, 50? (couldn't find a '10' in the code...)
# 4  
Old 04-27-2019
I figured it out: 50 would be;

if(NR < 51)

Smilie

Thanks again!
This User Gave Thanks to jenny-mac For This Post:
# 5  
Old 04-27-2019
Best to specify the character classification:
Code:
LC_CTYPE=C tr -dc 'A-Z' < /dev/urandom | .....

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

2. Shell Programming and Scripting

Split data into multiple lines

Hi, if i have data like below: Control|AC-00011-CN-2475208 AC-00011-CN-2475211 AC-00007-CN-2475238 AC-00007-CN-2475241 Im getting output in required format as below Control|AC-00011-CN-2475208 Control|AC-00011-CN-2475211 Control|AC-00007-CN-2475238 Control|AC-00007-CN-2475241 using awk... (9 Replies)
Discussion started by: JSKOBS
9 Replies

3. Shell Programming and Scripting

Extracting data from multiple lines

Hi All, I am stuck in one step.. I have one file named file.txt having content: And SGMT.perd_id = (SELECT cal.fiscal_perd_id FROM $ODS_TARGT.TIM_DT_CAL_D CAL FROM $ODS_TARGT.GL_COA_SEGMNT_XREF_A SGMT SGMT.COA_XREF_TYP_IDN In (SEL COA_XREF_TYP_IDN From... (4 Replies)
Discussion started by: Shilpi Gupta
4 Replies

4. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

5. UNIX for Dummies Questions & Answers

Extracting data between specific lines, multiple times

I need help extracting specific lines in a text file. The file looks like this: POSITION TOTAL-FORCE (eV/Angst) ----------------------------------------------------------------------------------- 1.86126 1.86973 1.86972 ... (14 Replies)
Discussion started by: captainalright
14 Replies

6. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

7. Shell Programming and Scripting

[AWK] handeling data spread on multiple lines

Hello all, first off great forum. Now for my little problem. Using RHEL 5.4 and awk. Been doing code since a few month. So just starting. My problem is handeling data on multiple lines. { if ($1 != LASTKEY && h ~ /.*\/s_fr_/) { checkgecos( h, h ) h="" ... (2 Replies)
Discussion started by: maverick72
2 Replies

8. Shell Programming and Scripting

How do you use pull data from multiple lines to do a for statement?

Guys I am having a problem with being able to find missing monitors in a configuration check script I am trying to create for accountability purposes for managing a large number of systems. What I am trying to do is run a script that will look at the raw config data in a file and pull all the pool... (7 Replies)
Discussion started by: scottzx7rr
7 Replies

9. Shell Programming and Scripting

Outputting data from multiple lines

Hi guys, looking for a bit of advise, and as I am a complete novice, please excuse the daft questions!! I have a list of events and of which entry looks like this; # # Event 1 # NAME = Event 1 # 12345 : 123 : 1 : 1 : L,1,N : 1,0 : Event # # Event 2 # NAME = Event 2 # 12346... (8 Replies)
Discussion started by: JayC89
8 Replies

10. UNIX for Dummies Questions & Answers

Split data into multiple lines

All, I have a requirement where I will need to split a line into multiple lines. Ex: Input: 2ABCDEFGH2POIYUY2ASDGGF2QWERTY Output: 2ABCDEFGH 2POIYUY 2ASDGGF 2QWERTY The data is of no fixed lenght. Only the lines have to start with 2. How can this be done. (5 Replies)
Discussion started by: kingofprussia
5 Replies
Login or Register to Ask a Question