Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk command input string too long, limit Post 303043627 by MadeInGermany on Sunday 2nd of February 2020 12:40:57 PM
Old 02-02-2020
Quote:
Originally Posted by knijjar
Thank you so much, can you please explain me what exactly you are doing. by the way it did work and thank you so much. I would like to understand your code.
Code:
while read -r junk other; do printf "%s\n" "$other"; done < filename

Thank you once again.
It is a while loop. In every cycle read a line into the two variables junk and other, where the first word lands in junk. The spaces around the first word are deleted. The source of the read is the file filename because the whole while-do-done block is redirected.
Then the variable other is printed.
The loop continues with the next read. It ends if the read fails, normally when it is beyond the last line (end of input reached).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Number of long limit

Hi Hi! I'm currently using AIX 5.2 and would like to know where can i find to see that there's a restriction on the number of login times a user can have. Example, I want give a 2 login per user but some one to give 3 login and some one have to give unlit login time (without logging off the... (2 Replies)
Discussion started by: herath
2 Replies

2. Programming

How i can read a long integer from standar input and a string with as many characters as specified..

how i can read a long integer from standar input and a string with as many characters as specified in the number? i thing that i must use the read command ofcourse.... (6 Replies)
Discussion started by: aintour
6 Replies

3. Shell Programming and Scripting

redirect an awk string output to a script input with pipes

Hi, I have a function in a bash script that returns a string after some operations using awk. The following code returns 555 $VARIABLE="EXAMPLE" get_number $VARIABLE this value I'd like to pass it as a second argument of another script with the following usage myscript.sh <param1>... (7 Replies)
Discussion started by: rid
7 Replies

4. Shell Programming and Scripting

Awk command without input file

i have a requirement to compare two time stamps in IF condition and return true whenever the second timestamp is greater than first, i will also be checking, if the timestamp in HHMMSS format( 6 digit time stamp ).Im able to achieve it using awk, however i dont want to give any input file to awk... (3 Replies)
Discussion started by: saikiran_1984
3 Replies

5. Shell Programming and Scripting

Variable as input to awk command

Hi Gurus, I need a suggestion, please help. I have a input file as below : abc.txt : * xxxx: 00000 xxxxx: 00000 xxxx: RANDOM xxx: RANDOM **************************xxxxxxx*** * abc ****************************** abc: abc: ... (3 Replies)
Discussion started by: arunshankar.c
3 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. UNIX for Dummies Questions & Answers

Multiple string input in a awk

Hi everybody, I just start my learning about Linux. So, if you can help me, it would be very good ! I have already find the possibility to find the position of a character regular expression in a line with the help of awk : test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL My script is... (2 Replies)
Discussion started by: thewizarde6
2 Replies

8. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

9. UNIX for Beginners Questions & Answers

How to put a 80 character limit on a long topic line in markdown?

I have a topic line in markdown that spans more than 80 characters that i need to add a line break. Markdown is simply treating the line break as a brand new line instead of continuing as a topic line. Eg: # This is a very long line Markdown interprets it as This is a very long line (4 Replies)
Discussion started by: dragonpoint
4 Replies

10. Shell Programming and Scripting

Limit on number of pipes after long-running command?

I'm trying to create a minimal, crude keylogger for X using only a shell script. I was quickly stumped: Why do these two commands entered in a terminal emulator produce output when I type... $ xinput test 6 | grep press $ xinput test 6 | awk '{print $3}' ...but this command produces no... (13 Replies)
Discussion started by: DevuanFan
13 Replies
bfs(1)								   User Commands							    bfs(1)

NAME
bfs - big file scanner SYNOPSIS
/usr/bin/bfs [-] filename DESCRIPTION
The bfs command is (almost) like ed(1) except that it is read-only and processes much larger files. Files can be up to 1024K bytes and 32K lines, with up to 512 characters, including new-line, per line (255 for 16-bit machines). bfs is usually more efficient than ed(1) for scanning a file, since the file is not copied to a buffer. It is most useful for identifying sections of a large file where csplit(1) can be used to divide it into more manageable pieces for editing. Normally, the size of the file being scanned is printed, as is the size of any file written with the w (write) command. The optional - sup- presses printing of sizes. Input is prompted with * if P and a carriage return are typed, as in ed(1). Prompting can be turned off again by inputting another P and carriage return. Note that messages are given in response to errors if prompting is turned on. All address expressions described under ed(1) are supported. In addition, regular expressions may be surrounded with two symbols besides / and ?: > indicates downward search without wrap-around, and < indicates upward search without wrap-around. There is a slight difference in mark names; that is, only the letters a through z may be used, and all 26 marks are remembered. bfs Commands The e, g, v, k, p, q, w, =, !, and null commands operate as described under ed(1). Commands such as ---, +++-, +++=, -12, and +4p are accepted. Note that 1,10p and 1,10 will both print the first ten lines. The f command only prints the name of the file being scanned; there is no remembered file name. The w command is independent of output diversion, truncation, or crunching (see the xo, xt, and xc com- mands, below). The following additional commands are available: xf file Further commands are taken from the named file. When an end-of-file is reached, an interrupt signal is received or an error occurs, reading resumes with the file containing the xf. The xf commands may be nested to a depth of 10. xn List the marks currently in use (marks are set by the k command). xo [file] Further output from the p and null commands is diverted to the named file, which, if necessary, is created mode 666 (readable and writable by everyone), unless your umask setting (see umask(1)) dictates otherwise. If file is missing, output is diverted to the stan- dard output. Note that each diversion causes truncation or creation of the file. : label This positions a label in a command file. The label is terminated by new-line, and blanks between the : (colon) and the start of the label are ignored. This command may also be used to insert comments into a command file, since labels need not be referenced. ( . , . )xb/regular expression/label A jump (either upward or downward) is made to label if the command succeeds. It fails under any of the following conditions: 1. Either address is not between 1 and $. 2. The second address is less than the first. 3. The regular expression does not match at least one line in the specified range, including the first and last lines. On success, . (dot) is set to the line matched and a jump is made to label. This command is the only one that does not issue an error message on bad addresses, so it may be used to test whether addresses are bad before other commands are executed. Note that the com- mand, xb/^/ label, is an unconditional jump. The xb command is allowed only if it is read from someplace other than a terminal. If it is read from a pipe, only a downward jump is possible. xt number Output from the p and null commands is truncated to, at most, number characters. The initial number is 255. xv[digit][spaces][value] The variable name is the specified digit following the xv. The commands xv5100 or xv5 100 both assign the value 100 to the variable 5. The command xv61,100p assigns the value 1,100p to the variable 6. To reference a variable, put a % in front of the variable name. For example, using the above assignments for variables 5 and 6: 1,%5p 1,%5 %6 will all print the first 100 lines. g/%5/p would globally search for the characters 100 and print each line containing a match. To escape the special meaning of %, a must pre- cede it. g/".*\%[cds]/p could be used to match and list %c, %d, or %s formats (for example, "printf"-like statements) of characters, decimal integers, or strings. Another feature of the xv command is that the first line of output from a UNIX system command can be stored into a variable. The only requirement is that the first character of value be an !. For example: .w junk xv5!cat junk !rm junk !echo "%5" xv6!expr %6 + 1 would put the current line into variable 35, print it, and increment the variable 36 by one. To escape the special meaning of ! as the first character of value, precede it with a . xv7!date stores the value !date into variable 7. xbz label xbn label These two commands will test the last saved return code from the execution of a UNIX system command (!command) or nonzero value, respectively, to the specified label. The two examples below both search for the next five lines containing the string size: Example 1: xv55 : l /size/ xv5!expr %5 - 1 !if 0%5 != 0 exit 2 xbn l Example 2: xv45 : l /size/ xv4!expr %4 - 1 !if 0%4 = 0 exit 2 xbz l xc [switch] If switch is 1, output from the p and null commands is crunched; if switch is 0, it is not. Without an argument, xc reverses switch. Initially, switch is set for no crunching. Crunched output has strings of tabs and blanks reduced to one blank and blank lines sup- pressed. OPERANDS
The following operand is supported: filename Any file up to 1024K bytes and 32K lines, with up to 512 characters, including new-line, per line (255 for 16-bit machines). filename can be a section of a larger file which has been divided into more manageable sections for editing by the use of csplit(1). EXIT STATUS
The following exit values are returned: 0 Successful completion without any file or command errors. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ SEE ALSO
csplit(1), ed(1), umask(1), attributes(5) DIAGNOSTICS
Message is ? for errors in commands, if prompting is turned off. Self-explanatory error messages are displayed when prompting is on. SunOS 5.11 20 May 1996 bfs(1)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy