Sponsored Content
Top Forums Shell Programming and Scripting String searching and output to a file in a formatted text Post 302438511 by rdcwayx on Tuesday 20th of July 2010 03:03:46 AM
Old 07-20-2010
Quote:
Originally Posted by cuji
hi rdc, thx for your prompt reply. i got "awk: Input line <Jun 29, 2010 5:24:3 cannot be longer than 3,000 bytes.
The input line number is 1. The file is batch-host.log.6.
The source line number is 1." message when running the script u provided. I tried to use below script instead:-

grep -h "TTOH 8031950001" *batch-host.log* |cut -d " " -f2-14 >test.log

but got attached output (missing 1st 4 bytes). Perhaps few items need to amended using above script?.

Thanks a lot ya..
Looks you saw my old post before I updated to awk command? I used cut first, because it is easy to get column 2 to 14, but seems there are more spaces between each column. such as "TTOH 8031950001" has 3 spaces between them. That's why I updated to awk command.

What you can do now is, adjust the range, maybe from 2 to 20 or something else.

For the awk command, I test succesfully in my system with your file batch-host.log.6. If your system is solaris, use /usr/bin/nawk or /usr/xpg4/bin/awk
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Hi! Searching for a text string in UNIX

Hi! I'm new here and glad to meet everyone! I've been wrestling with a problem lately however! How do I recursively (recursive means to keep going through the subdirectories until no more are there) search a bunch of textfiles in a long directory structure for a specific string.. but only... (1 Reply)
Discussion started by: skwadim
1 Replies

2. Shell Programming and Scripting

Convert DATE string to a formatted text

Hi guys, i need your help. I need to convert a date like this one 20071003071023 , to a formated date like 20071003 07:10:23 . Could this be possible ? Regards, Osramos (6 Replies)
Discussion started by: osramos
6 Replies

3. Shell Programming and Scripting

Searching and extracting text from output

I have the following output which I need to obtain the values for "Next Seq is xxx" and "Last Seq is xxx" and "Pending count is xxx". You will notice that the number of words prior to that value can be variable hence the reason for asking this question. LINECMD> Line /xxx///ABC9_SND is UP.... (3 Replies)
Discussion started by: sjday
3 Replies

4. Shell Programming and Scripting

PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines. for example the text output is: United Chanmpions Ronaldo Liverpool Losers Torres and my script code is print("DEBUG - checking file message"); while... (15 Replies)
Discussion started by: meevagh
15 Replies

5. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

6. Shell Programming and Scripting

searching a text string for n'th :

hello, i'm a novice on bsh scripting so thanks for any help here basically i have a shell var $x that looks like this > echo $x nabc1234:!:73394:17155:Gary Mason:/home/garym:/bin/ksh and i'm trying to keep the first 8 characters and the text from the 4th : to the 5th : i've been trying... (9 Replies)
Discussion started by: sasglm
9 Replies

7. Shell Programming and Scripting

Searching for a particular string and modifying text within block of data

Hi Forum. Is there a quick way to do the following search/replace within a block of data? I tried to google the solution but didn't really know what to look for. I have the following text file (I want to search for a particular string "s_m_f_acct_txn_daily_a1" and replace the... (5 Replies)
Discussion started by: pchang
5 Replies

8. 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

9. HP-UX

Formatted TOP command output in file

Hi All, I want generate HP-UX overall system performance report. I tried executing top command and write that out put to file. but am not able to view the report in proper format. I can see report like below in file but i can see properly in terminal. Please suggest how can i get... (2 Replies)
Discussion started by: lravip123
2 Replies

10. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies
INTRO(1)						    BSD General Commands Manual 						  INTRO(1)

NAME
intro -- introduction to general commands (tools and utilities) DESCRIPTION
Section one of the manual contains most of the commands which comprise the BSD user environment. Some of the commands included in section one are text editors, command shell interpreters, searching and sorting tools, file manipulation commands, system status commands, remote file copy commands, mail commands, compilers and compiler tools, formatted output tools, and line printer commands. All commands set a status value upon exit which may be tested to see if the command completed normally. The exit values and their meanings are explained in the individual manuals. Traditionally, the value 0 signifies successful completion of the command. SEE ALSO
man(1), intro(2), intro(3), intro(4), intro(5), intro(6), intro(7), intro(8), intro(9) The Regents of the University of California, UNIX User's Manual Supplementary Documents, University of California, Berkeley, http://www.netbsd.org/docs/bsd/lite2/usd.html, June, 1993. HISTORY
An intro(1) manual appeared in Version 6 AT&T UNIX. BSD
May 5, 2010 BSD
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy