Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replace Forward Slash with sed Post 302560011 by depakjan on Wednesday 28th of September 2011 04:03:03 PM
Old 09-28-2011
This is the sample

Code:
 
declare
act_errors number(10, 0);
at_least_one_exception EXCEPTION;
err_num NUMBER;
err_msg VARCHAR2(1000);
begin
act_errors := 0;
dbms_output.put_line('Starting to process  '|| 'cdd');
begin
insert into CS_CASE
(CASE_ID,id,desc) VALUES
('c12', 
'nbkany2' , 
'Credit Card
/
card' , 
);
exception
when others then
act_errors := 28;
err_num := SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 1000);
dbms_output.put_line('Statement number ' || act_errors || ' failed (search for "act_errors := ' || act_errors || '" in the source file)');
dbms_output.put_line(err_msg );
end;
/
(blank line here)
(blank line here)

and the output should be

Code:
 
declare
act_errors number(10, 0);
at_least_one_exception EXCEPTION;
err_num NUMBER;
err_msg VARCHAR2(1000);
begin
act_errors := 0;
dbms_output.put_line('Starting to process  '|| 'cdd');
begin
insert into CS_CASE
(CASE_ID,id,desc) VALUES
('c12', 
'nbkany2' , 
'Credit Card
\/
card' , 
);
exception
when others then
act_errors := 28;
err_num := SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 1000);
dbms_output.put_line('Statement number ' || act_errors || ' failed (search for "act_errors := ' || act_errors || '" in the source file)');
dbms_output.put_line(err_msg );
end;
/
(blank line here) 
(blank line here)

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep for forward slash

How can I use grep to grab a line that contains a forward slash? I've tried: grep "/pd " file, Inevitably it just grabs pd not /pd. (3 Replies)
Discussion started by: wxornot
3 Replies

2. Shell Programming and Scripting

Help with SED and forward slash

Using the script: (Called replaceit) #!/bin/ksh String=$1 Replace=$2 sed -e "s/${orig}/${new}/g" oldfile.txt > newfile.txt In oldfile.txt, I'm looking for: getenv("Work") And change it To: /u/web I execute the script: replaceit "getenv(\""Work\"")" /u/web I'm getting sed... (3 Replies)
Discussion started by: gseyforth
3 Replies

3. Shell Programming and Scripting

escaping / (forward slash)

how to escape / (forward slash) in a string. I have following scnerio: sed s/${var1}{$var2} var1 and var2 both contain slashes, but sed gives error if there is a slash in var1 or var2. sed is used here to replace var1 with var2. Thanks in advance (1 Reply)
Discussion started by: farooqpervaiz
1 Replies

4. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

5. Shell Programming and Scripting

How to replace comma by slash using sed in an UTF8 file

Hello all, I'd like to replace "," by "/" in a utf8 file from postion X to Y. Comma "," is also defined as delimiter. 12345678901234567890,123456789012345,12345678901234567890, aaaa,aaaa,aaaaa ,bbb,bbbb,bbbbb ,cccccc,cc , Result should be... (1 Reply)
Discussion started by: fmofmo
1 Replies

6. Shell Programming and Scripting

Significance of forward slash(/) while specifying a directory

What is the significance of the forward slash(/) while specifying a directory? cp -av /dir/ /opt/ and cp -av /dir /opt Does effectively the same job it seems? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

7. Shell Programming and Scripting

AWK or SED to replace forward slash

hi hope somebody can help, there seems to be bit on the net about this, but still cant make it work the way i need. i have a file live this mm dd ff /dev/name1 mm dd ff /dev/name2 mm dd ff /dev/name3 mm dd ff /dev/name4 i need to update /dev/name1 etc to /newdev/new/name1 etc so... (5 Replies)
Discussion started by: dshakey
5 Replies

8. Shell Programming and Scripting

sed command to replace slash in date format only

Hello experts. I haven't been able to find a solution for this using the sed command. I only want to replace the forward slash with string "FW_SLASH" only if there's a number right after the slash while preserving the original number. I have a file containing 2 entries: Original File:... (5 Replies)
Discussion started by: pchang
5 Replies

9. Shell Programming and Scripting

Escaping Forward Slash

./split2.sh: line 1: split/ssl/pop3s.txt: No such file or directory sort: cannot read: split/ssl/pop3s.txt: No such file or directory Hi there, I am pulling data from the following source: ssl/http ssl/http ssl/http-alt ssl/https ssl/https ssl/https ssl/https ssl/https ssl/https... (3 Replies)
Discussion started by: alvinoo
3 Replies

10. UNIX for Beginners Questions & Answers

Replace string until 3Rd occurance of forward slash(/)

I have a file abc.txt which has records like 456 /home/fgg/abdc.txt 3567 /home/fdss/vfgb.txt 23 /home/asd/dfght.txt I WANT TO REMOVE STRING UNTIL 3RD OCCURANCE OF FORWARD SLASH Output should be like abdc.txt vfgb.txt dfght.txt (5 Replies)
Discussion started by: himanshupant
5 Replies
SEM_TIMEDWAIT(3P)					     POSIX Programmer's Manual						 SEM_TIMEDWAIT(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
sem_timedwait -- lock a semaphore SYNOPSIS
#include <semaphore.h> #include <time.h> int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict abstime); DESCRIPTION
The sem_timedwait() function shall lock the semaphore referenced by sem as in the sem_wait() function. However, if the semaphore cannot be locked without waiting for another process or thread to unlock the semaphore by performing a sem_post() function, this wait shall be termi- nated when the specified timeout expires. The timeout shall expire when the absolute time specified by abstime passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abstime), or if the absolute time specified by abstime has already been passed at the time of the call. The timeout shall be based on the CLOCK_REALTIME clock. The resolution of the timeout shall be the resolution of the clock on which it is based. The timespec data type is defined as a structure in the <time.h> header. Under no circumstance shall the function fail with a timeout if the semaphore can be locked immediately. The validity of the abstime need not be checked if the semaphore can be locked immediately. RETURN VALUE
The sem_timedwait() function shall return zero if the calling process successfully performed the semaphore lock operation on the semaphore designated by sem. If the call was unsuccessful, the state of the semaphore shall be unchanged, and the function shall return a value of -1 and set errno to indicate the error. ERRORS
The sem_timedwait() function shall fail if: EINVAL The process or thread would have blocked, and the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. ETIMEDOUT The semaphore could not be locked before the specified timeout expired. The sem_timedwait() function may fail if: EDEADLK A deadlock condition was detected. EINTR A signal interrupted this function. EINVAL The sem argument does not refer to a valid semaphore. The following sections are informative. EXAMPLES
The program shown below operates on an unnamed semaphore. The program expects two command-line arguments. The first argument specifies a seconds value that is used to set an alarm timer to generate a SIGALRM signal. This handler performs a sem_post(3) to increment the sema- phore that is being waited on in main() using sem_timedwait(). The second command-line argument specifies the length of the timeout, in seconds, for sem_timedwait(). #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #include <time.h> #include <assert.h> #include <errno.h> #include <signal.h> sem_t sem; static void handler(int sig) { int sav_errno = errno; static const char info_msg[] = "sem_post() from handler "; write(STDOUT_FILENO, info_msg, sizeof info_msg - 1); if (sem_post(&sem) == -1) { static const char err_msg[] = "sem_post() failed "; write(STDERR_FILENO, err_msg, sizeof err_msg - 1); _exit(EXIT_FAILURE); } errno = sav_errno; } int main(int argc, char *argv[]) { struct sigaction sa; struct timespec ts; int s; if (argc != 3) { fprintf(stderr, "Usage: %s <alarm-secs> <wait-secs> ", argv[0]); exit(EXIT_FAILURE); } if (sem_init(&sem, 0, 0) == -1) { perror("sem_init"); exit(EXIT_FAILURE); } /* Establish SIGALRM handler; set alarm timer using argv[1] */ sa.sa_handler = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGALRM, &sa, NULL) == -1) { perror("sigaction"); exit(EXIT_FAILURE); } alarm(atoi(argv[1])); /* Calculate relative interval as current time plus number of seconds given argv[2] */ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { perror("clock_gettime"); exit(EXIT_FAILURE); } ts.tv_sec += atoi(argv[2]); printf("main() about to call sem_timedwait() "); while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR) continue; /* Restart if interrupted by handler */ /* Check what happened */ if (s == -1) { if (errno == ETIMEDOUT) printf("sem_timedwait() timed out "); else perror("sem_timedwait"); } else printf("sem_timedwait() succeeded "); exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE); } APPLICATION USAGE
Applications using these functions may be subject to priority inversion, as discussed in the Base Definitions volume of POSIX.1-2008, Sec- tion 3.287, Priority Inversion. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
sem_post(), sem_trywait(), semctl(), semget(), semop(), time() The Base Definitions volume of POSIX.1-2008, Section 3.287, Priority Inversion, <semaphore.h>, <time.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Stan- dard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html . Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . IEEE
/The Open Group 2013 SEM_TIMEDWAIT(3P)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy