Sponsored Content
Top Forums Shell Programming and Scripting Searching for a token in a file Post 302877584 by RudiC on Monday 2nd of December 2013 11:37:31 AM
Old 12-02-2013
Never change horses. If you use awk, try to do as much as possible in it (like Yoda's approach). If you start with shell scripting, try to stick to it. It is possible in shell, assuming filearray ist assigned from token.txt:
Code:
while read TOKEN REST
  do for ((i=0; i<${#filearray[@]}; i++))   
     do     [ "$REST" != "${REST/${filearray[$i]}/}" ] && echo ${filearray[$i]} $TOKEN
     done
 done <flat.txt
abc 123
der 234
xyz 345

And, don't open and read flat.txt several times. Memory access is far faster, so loop the array several times.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sendmail.cf: How can I read a .db file and search for a token?

Hello, I need to write code in '/etc/mail/sendmail.cf' to verify that a string exists within a hash file ( Such as /etc/mail/key-value.db ). I've searched the web and did find many great articles regarding 'sendmail.cf' however I'm not clear how I can do this specific thing as the online... (0 Replies)
Discussion started by: Devyn
0 Replies

2. Shell Programming and Scripting

Append a field to the end of each line of a file based on searching another file.

Hi All, I have two comma separated value(CSV) files, say FileA and FileB. The contents looks like that shown below. FileA EmpNo,Name,Age,Sex, 1000,ABC,23,M, 1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies

3. Shell Programming and Scripting

searching a log file and appending to a .txt file

I'm new to shell scripting and am writing a script to help me log the free memory and hd space on a server. As of now, the script just runs 'df -h' and appends the output to a file and then runs 'top' and appends the output to a log file. What I want to do, is have the script also search the... (3 Replies)
Discussion started by: enator45
3 Replies

4. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

5. Shell Programming and Scripting

syntax error near unexpected token `for file in

I am trying to run the code below however I am getting a "syntax error near unexpected token `for file in error" on the line that is in red. I have the semicolons after every line because it will fail on the copy if I don't have them saying that it cannot stat directory. Is there something that I... (3 Replies)
Discussion started by: coach5779
3 Replies

6. UNIX for Dummies Questions & Answers

Help with searching for a file in a directory and copying the contents of that file in a new file

Hi guys, I am a newbie here :wall: I need a script that can search for a file in a directory and copy the contents of that file in a new file. Please help me. :confused: Thanks in advance~ (6 Replies)
Discussion started by: zel2zel
6 Replies

7. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

8. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

9. Shell Programming and Scripting

sed - searching token in certain order

Hello. I would like to write a bash function which would return "true" if the search succeed else return anything else. something like if ] ; then exit 1 fi function my_funct () { find first occurrence $2 in $1 if not found return "false" from that position,... (6 Replies)
Discussion started by: jcdole
6 Replies

10. Shell Programming and Scripting

Searching a file inside a .tar.gz file by date

Hi, I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date? Thanks! (4 Replies)
Discussion started by: erin00
4 Replies
yhsm-init-oath-token(1) 				      General Commands Manual					   yhsm-init-oath-token(1)

NAME
yhsm-init-oath-token - Tool to add an OATH token to the yhsm-validation-server(1) database. SYNOPSIS
yhsm-init-oath-token --key-handle kh --uid name [options] DESCRIPTION
Use this tool to add OATH token entrys to the yhsm-validation-server(1) database. OPTIONS
-D, --device device file name (default: /dev/ttyACM0) -v, --verbose enable verbose operation --debug enable debug printout, including all data sent to/from YubiHSM --force overwrite any present entry --key-handle kh key handle to create AEAD. Examples : "1", "0xabcd". --uid name user id (lookup key in token database) --oath-c num initial OATH counter value (integer) --test-oath-window num number of codes to search with --test-code --test-code digits optional OTP from token for verification --oath-k str secret HMAC-SHA-1 key of the token, hex encoded --db-file fn db file for storing AEADs for later use by the yhsm-validation-server(1) (default: /var/yubico/yhsm-validation-server.db) EXIT STATUS
0 YubiHSM keystore successfully unlocked 1 Failed to unlock keystore 255 Client ID not found in internal database BUGS
Report python-pyhsm/yhsm-init-oath-token bugs in the issue tracker <https://github.com/Yubico/python-pyhsm/issues/> SEE ALSO
The python-yubico home page <https://github.com/Yubico/python-pyhsm/> YubiHSMs can be obtained from Yubico <http://www.yubico.com/>. python-pyhsm December 2011 yhsm-init-oath-token(1)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy