Sponsored Content
Full Discussion: Sed Question?
Top Forums Shell Programming and Scripting Sed Question? Post 302163969 by ghostdog74 on Sunday 3rd of February 2008 08:39:06 PM
Old 02-03-2008
Code:
#!/bin/sh
s="12-13 15-18 23-28 36-38 42-43 53-56 70-72 76 80-86 93-110 119-128"
echo $s | awk '
{
  for (i=1;i<=NF;i++){
    n=split($i,a,"-")
    for (j=a[1];j<=a[n];j++){
        printf  "%d " ,j  
    }
    print ""
  }
}'

output:
Code:
# ./test.sh
12 13
15 16 17 18
23 24 25 26 27 28
36 37 38
42 43
53 54 55 56
70 71 72
76
80 81 82 83 84 85 86
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
119 120 121 122 123 124 125 126 127 128

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed Question

Hi, Is there any way to traverse the file once and look for the following conditions in one sweep instead of going over the file 3 times with different search criteria...... sed -n '/^ORA-07445/ p' /tmp/t$$ > ${OERRFILE} sed -n '/^ORA-00600/ p' /tmp/t$$ >> ${OERRFILE} ... (1 Reply)
Discussion started by: YS2002
1 Replies

2. Shell Programming and Scripting

sed question (again)

hello there, I have a sed question. I have a file (temp.srv), in it it has v1_host1 v2_host2 And I have another file (temp2.srv), in it is has v1_host3_date v1_host1 v2_host2 v2_host4_date v3_host5_date I had used a script to remove the name from temp2.srv base on the name inside... (3 Replies)
Discussion started by: ahtat99
3 Replies

3. Shell Programming and Scripting

sed question

Hi, When deleting lines using sed, as i understand the lines are redirected to the standard output. What i'm unclear about is how to actually modify the file? If I write the command sed '1,2d' test it will display lines one and 2 onto the screen however the file is not modified? I think my... (5 Replies)
Discussion started by: c19h28O2
5 Replies

4. Shell Programming and Scripting

sed question

Hi, :) can any body explain the following statement sed 's/\(\)- ]//g' cheers RRK (3 Replies)
Discussion started by: ravi raj kumar
3 Replies

5. Shell Programming and Scripting

sed question

I have a file that conatins following info Policy1=U|guestRoom=test1idCode=5(1):!:Amenity2=U|RoomId=testrma=4(1):!:| GuestRoomAmenity1=U|guestRoomId=testguest1id^rmaCode=5(1):!:| I need it to look like this Policy1=U|guestRoom=test1idCode Amenity2=U|RoomId=testrmaCode... (2 Replies)
Discussion started by: arushunter
2 Replies

6. UNIX for Dummies Questions & Answers

sed question

How would I use sed to print everything on the line after the regular expresion? I have a configuration file setting several variables. cfg.dat DDB = cpptest SUDBNAME = sucpptestdb host = cpptest Example I want to search for the regular expresion 'SUDBNAME =' and print everything on... (3 Replies)
Discussion started by: orahi001
3 Replies

7. Shell Programming and Scripting

Sed Question 1. (Don't quite know how to use sed! Thanks)

Write a sed script to extract the year, rank, and stock for the most recent 10 years available in the file top10_mktval.csv, and output in the following format: ------------------------------ YEAR |RANK| STOCK ------------------------------ 2007 | 1 | Exxon... (1 Reply)
Discussion started by: beibeiatNY
1 Replies

8. Shell Programming and Scripting

sed question

hi i have a file with this line: variable=/export/home/oracle I want to change the file so that the path is replaced with the value of another variable var2=/tmp/anything. how to do this in sed? thx (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

9. Shell Programming and Scripting

Sed question

I need to replace the numbers with a new string. How can I give a wildcard for the different # of numbers sed '/abcdef/s/abcdef=*/abcdef=999999/'<foo>foo1 From: To: abcdef=1234 abcdef=999999 abcdef=12345 abcdef=999999 abcdef=123456... (10 Replies)
Discussion started by: beppler
10 Replies

10. UNIX for Dummies Questions & Answers

SED question

I am trying to write a script that will take an input text file in the format person: place: phonenumber; person: place: phonenumber; person: place: phonenumber; ... and output it using sed too: Name ######## Location ######### Phone Number... (1 Reply)
Discussion started by: jmack56
1 Replies
IMAP_OPEN(3)								 1							      IMAP_OPEN(3)

imap_open - Open anIMAPstream to a mailbox

SYNOPSIS
resource imap_open NULL (string $mailbox, string $username, string $password, [int $options], [int $n_retries], [array $params]) DESCRIPTION
Opens an IMAP stream to a $mailbox. This function can also be used to open streams to POP3 and NNTP servers, but some functions and features are only available on IMAP servers. PARAMETERS
o $mailbox - A mailbox name consists of a server and a mailbox path on this server. The special name INBOX stands for the current users per- sonal mailbox. Mailbox names that contain international characters besides those in the printable ASCII space have to be encoded width imap_utf7_encode(3). The server part, which is enclosed in '{' and '}', consists of the servers name or ip address, an optional port (prefixed by ':'), and an optional protocol specification (prefixed by '/'). The server part is mandatory in all mailbox parameters. All names which start with { are remote names, and are in the form "{" remote_system_name [":" port] [flags] "}" [mailbox_name] where: o remote_system_name - Internet domain name or bracketed IP address of server. o port - optional TCP port number, default is the default port for that service o flags - optional flags, see following table. o mailbox_name - remote mailbox name, default is INBOX Optional flags for names +---------------------------------------------+---------------------------------------------------+ | Flag | | | | | | | Description | | | | +---------------------------------------------+---------------------------------------------------+ | | | | /service= service | | | | | | | mailbox access service, default is "imap" | | | | | | | | /user= user | | | | | | | remote user name for login on the server | | | | | | | | /authuser= user | | | | | | | remote authentication user; if specified this is | | | the user name whose password is used (e.g. admin- | | | istrator) | | | | | | | | /anonymous | | | | | | | remote access as anonymous user | | | | | | | | /debug | | | | | | | record protocol telemetry in application's debug | | | log | | | | | | | | /secure | | | | | | | do not transmit a plaintext password over the | | | network | | | | | | | |/imap, /imap2, /imap2bis, /imap4, /imap4rev1 | | | | | | | equivalent to /service=imap | | | | | | | | /pop3 | | | | | | | equivalent to /service=pop3 | | | | | | | | /nntp | | | | | | | equivalent to /service=nntp | | | | | | | | /norsh | | | | | | | do not use rsh or ssh to establish a preauthenti- | | | cated IMAP session | | | | | | | | /ssl | | | | | | | use the Secure Socket Layer to encrypt the ses- | | | sion | | | | | | | | /validate-cert | | | | | | | validate certificates from TLS/SSL server (this | | | is the default behavior) | | | | | | | | /novalidate-cert | | | | | | | do not validate certificates from TLS/SSL server, | | | needed if server uses self-signed certificates | | | | | | | | /tls | | | | | | | force use of start-TLS to encrypt the session, | | | and reject connection to servers that do not sup- | | | port it | | | | | | | | /notls | | | | | | | do not do start-TLS to encrypt the session, even | | | with servers that support it | | | | | | | | /readonly | | | | | | | request read-only mailbox open (IMAP only; | | | ignored on NNTP, and an error with SMTP and POP3) | | | | +---------------------------------------------+---------------------------------------------------+ o $username - The user name o $password - The password associated with the $username o $options - The $options are a bit mask with one or more of the following: o OP_READONLY - Open mailbox read-only o OP_ANONYMOUS - Don't use or update a .newsrc for news (NNTP only) o OP_HALFOPEN - For IMAP and NNTP names, open a connection but don't open a mailbox. o CL_EXPUNGE - Expunge mailbox automatically upon mailbox close (see also imap_delete(3) and imap_expunge(3)) o OP_DEBUG - Debug protocol negotiations o OP_SHORTCACHE - Short ( elt-only) caching o OP_SILENT - Don't pass up events (internal use) o OP_PROTOTYPE - Return driver prototype o OP_SECURE - Don't do non-secure authentication o $n_retries - Number of maximum connect attempts o $params - Connection parameters, the following (string) keys maybe used to set one or more connection parameters: o DISABLE_AUTHENTICATOR - Disable authentication properties RETURN VALUES
Returns an IMAP stream on success or FALSE on error. CHANGELOG
+--------+------------------+ |Version | | | | | | | Description | | | | +--------+------------------+ | 5.3.2 | | | | | | | $params added | | | | | 5.2.0 | | | | | | | $n_retries added | | | | +--------+------------------+ EXAMPLES
Example #1 Different use of imap_open(3) <?php // To connect to an IMAP server running on port 143 on the local machine, // do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password"); // To connect to a POP3 server on port 110 on the local server, use: $mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password"); // To connect to an SSL IMAP or POP3 server, add /ssl after the protocol // specification: $mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password"); // To connect to an SSL IMAP or POP3 server with a self-signed certificate, // add /ssl/novalidate-cert after the protocol specification: $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password"); // To connect to an NNTP server on port 119 on the local server, use: $nntp = imap_open ("{localhost:119/nntp}comp.test", "", ""); // To connect to a remote server replace "localhost" with the name or the // IP address of the server you want to connect to. ?> Example #2 imap_open(3) example <?php $mbox = imap_open("{imap.example.org:143}", "username", "password"); echo "<h1>Mailboxes</h1> "; $folders = imap_listmailbox($mbox, "{imap.example.org:143}", "*"); if ($folders == false) { echo "Call failed<br /> "; } else { foreach ($folders as $val) { echo $val . "<br /> "; } } echo "<h1>Headers in INBOX</h1> "; $headers = imap_headers($mbox); if ($headers == false) { echo "Call failed<br /> "; } else { foreach ($headers as $val) { echo $val . "<br /> "; } } imap_close($mbox); ?> SEE ALSO
imap_close(3). PHP Documentation Group IMAP_OPEN(3)
All times are GMT -4. The time now is 08:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy