Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Awk/bash one liner replacement for a if condition Post 303041713 by ctrld on Monday 2nd of December 2019 10:45:12 AM
Old 12-02-2019
Thank you for confirming Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bad day !! test condition failed --need a one liner to do --help

Hi all this is simple but bad day for me nothing work out .. Problem is that I wan to check the argument passed to my script and accordignly exit or setup ENV variable I have a script name src_cpcp_preproc.sh i want to pass 2 argumet from command line argumet and check it in the script... (13 Replies)
Discussion started by: jambesh
13 Replies

2. UNIX for Dummies Questions & Answers

Awk/Sed One liner for text replacement

Hi group, I want to replace the occurance of a particular text in a paragraph.I tried with Sed,but Sed only displays the result on the screen.How can i update the changes in the original file??? The solution should be a one liner using awk and sed. Thanks in advance. (5 Replies)
Discussion started by: bishnu.bhatta
5 Replies

3. Shell Programming and Scripting

Bash one liner to CSH

Hello all, I have a Bash command I'm using on one system that replaces text in filenames, I'ts not working on another system that uses the Csh shell. Can anyone tell me what I need to do when i run for f in *;do mv $f ${f/text1/text2};done on the CSH shell i get ""Missing }."" (7 Replies)
Discussion started by: mike171562
7 Replies

4. Shell Programming and Scripting

Bash replacement to getchar

There's a replacement in bash for getchar or get functions of C and C++?Those functions read the next char avaliable in the input stream. I've tried something like: OLD_STTY=`stty -g` stty cbreak -echo look=`dd if=/dev/tty bs=1 count=1 2>/dev/null` stty $OLD_STTY But it is not working... (3 Replies)
Discussion started by: Asafe
3 Replies

5. UNIX for Dummies Questions & Answers

awk one liner

I need a one liner to" find /pattern/ print from x lines before "pattern" to y lines after "pattern" (3 Replies)
Discussion started by: kenneth.mcbride
3 Replies

6. Shell Programming and Scripting

Bash string replacement - how to use regex?

Hello I have a bash script where I need to do a substring replacement like this: variable2=${variable1/foo/bar} However, I only want "foo" replaced if it is at the end of the line. However, this does not work: variable2=${variable1/foo$/bar} as you can see I'm using the $ regex for... (2 Replies)
Discussion started by: Ubuntu-UK
2 Replies

7. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

8. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

9. Programming

Resample time series data with replacement any way to do this in awk or just bash script

I have some time series data that I need to resample or downsample at some specific time intervals. The firs column is time in decimal hours. I am tryiong to resample this data every 3 minutse. So I need a data value ever 0.05. Here is the example data and as you can see, there time slot for 0.1500... (3 Replies)
Discussion started by: malandisa
3 Replies

10. UNIX for Beginners Questions & Answers

Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi I want to replace time stamp in the following line PROCNAME.Merge.exchMon.CODE.T_QSTART 08:45 read assuming the new time stamp is 09:45 ; the line is getting replaced as below :45 read I'm trying to use the perl one liner in bash script perl -pi... (4 Replies)
Discussion started by: charlie87
4 Replies
ACCEPT(2)						      BSD System Calls Manual							 ACCEPT(2)

NAME
accept -- accept a connection on a socket SYNOPSIS
#include <sys/socket.h> int accept(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len); DESCRIPTION
The argument socket is a socket that has been created with socket(2), bound to an address with bind(2), and is listening for connections after a listen(2). accept() extracts the first connection request on the queue of pending connections, creates a new socket with the same properties of socket, and allocates a new file descriptor for the socket. If no pending connections are present on the queue, and the socket is not marked as non-blocking, accept() blocks the caller until a connection is present. If the socket is marked non-blocking and no pending connections are present on the queue, accept() returns an error as described below. The accepted socket may not be used to accept more con- nections. The original socket socket, remains open. The argument address is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer. The exact format of the address parameter is determined by the domain in which the communication is occurring. The address_len is a value- result parameter; it should initially contain the amount of space pointed to by address; on return it will contain the actual length (in bytes) of the address returned. This call is used with connection-based socket types, currently with SOCK_STREAM. It is possible to select(2) a socket for the purposes of doing an accept() by selecting it for read. For certain protocols which require an explicit confirmation, such as ISO or DATAKIT, accept() can be thought of as merely dequeuing the next connection request and not implying confirmation. Confirmation can be implied by a normal read or write on the new file descriptor, and rejection can be implied by closing the new socket. One can obtain user connection request data without confirming the connection by issuing a recvmsg(2) call with an msg_iovlen of 0 and a non- zero msg_controllen, or by issuing a getsockopt(2) request. Similarly, one can provide user connection rejection information by issuing a sendmsg(2) call with providing only the control information, or by calling setsockopt(2). RETURN VALUES
The call returns -1 on error and the global variable errno is set to indicate the error. If it succeeds, it returns a non-negative integer that is a descriptor for the accepted socket. ERRORS
The accept() system call will fail if: [EBADF] socket is not a valid file descriptor. [ECONNABORTED] The connection to socket has been aborted. [EFAULT] The address parameter is not in a writable part of the user address space. [EINTR] The accept() system call was terminated by a signal. [EINVAL] socket is unwilling to accept connections. [EMFILE] The per-process descriptor table is full. [ENFILE] The system file table is full. [ENOMEM] Insufficient memory was available to complete the operation. [ENOTSOCK] socket references a file type other than a socket. [EOPNOTSUPP] socket is not of type SOCK_STREAM and thus does not accept connections. [EWOULDBLOCK] socket is marked as non-blocking and no connections are present to be accepted. LEGACY SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> The include file <sys/types.h> is necessary. SEE ALSO
bind(2), connect(2), connectx(2), listen(2), select(2), socket(2), compat(5) HISTORY
The accept() function appeared in 4.2BSD. 4.2 Berkeley Distribution March 18, 2015 4.2 Berkeley Distribution
All times are GMT -4. The time now is 11:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy