Sponsored Content
Full Discussion: Substring using sed or awk
Top Forums Shell Programming and Scripting Substring using sed or awk Post 302376585 by daptal on Tuesday 1st of December 2009 08:12:29 PM
Old 12-01-2009
Code:
cat abc.txt
REPLYFILE=myfile.txt
myfile.txt.gz.20091120.enc
REPLYFILE=myfile.txt.gz.20091120.enc

Code:
sed 's/.*=//g;s/\.gz.*//g' abc.txt

chk if this helps.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed, grep, awk, regex -- extracting a matched substring from a file/string

Ok, I'm stumped and can't seem to find relevant info. (I'm not even sure, I might have asked something similar before.): I'm trying to use shell scripting/UNIX commands to extract URLs from a fairly large web page, with a view to ultimately wrapping this in PHP with exec() and including the... (2 Replies)
Discussion started by: ropers
2 Replies

2. Shell Programming and Scripting

Sed extract substring on (OS X)

On OS 10.4.11 I have filenames like: 670711 SA T2 v1-1_DS_EF.doc CT_670520 AM T1 v1-2_DS_EF.doc CT_670716 - 2 SA T4 v1-2_DS_EF.doc CT_670713 SA T3 v1-1_DS_EF.doc 670421 PA DYP1 v1-1_DS_EF.doc CT_670425 PA DYP2 v1-1_DS_EF.doc CT_670107 RA T3 v1-2_DS_EF.doc CT_670521 AM T2 v1-2_DS_EF.doc... (3 Replies)
Discussion started by: mlommel
3 Replies

3. Shell Programming and Scripting

Using sed to get a substring

Hi, I have looked all over for this. I am attempting to get a the substring of a string using sed since it seemed the best solution for this. For example my string is: "zzz foo to you and bar123 or foo" I would like to extract the text between "and" and "or" (it could be anything, but... (2 Replies)
Discussion started by: CentaurAtlas
2 Replies

4. Shell Programming and Scripting

Sed and SubString

Hi Folks, I am here with a simple doubt. I am having a flat file in which I want to replace the characters from say 5 to 15 as some text. Flat file contains a single line. For example 01MRRAJESH21000RAJESH INDUSTRIES In the above line pos 16-21 is Rajesh, I want to search for the... (4 Replies)
Discussion started by: dinesh1985
4 Replies

5. Shell Programming and Scripting

Making substring with sed

Input: You can easily do this by highlighting your code. How can i get the substring from index 9 to 12 using sed? (6 Replies)
Discussion started by: cola
6 Replies

6. Shell Programming and Scripting

Substring using cut/awk/sed

Hi Gurus,I have a seemingly simple problem but struggling with it.It is as follows : I/p string - ABCDEFGHIJ20100909.txt desired o/p - AB,DEF,20100909,ABCDEFGHIJ20100909.txt How to achieve it ?Thanks in advance. Please use code tags, thank you (20 Replies)
Discussion started by: sumoka
20 Replies

7. Shell Programming and Scripting

Extract a substring using SED/AWK

Hi All, I have a log file in which name and version of applications are coming in the following format name It may look like following, based on the name of the application and version: XYZ OR xyz OR XyZ OR xyz I want to separate out the name and version and store them into variables.... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

8. Shell Programming and Scripting

Using sed to find a substring from a file

HI All, I have a file which looks like below ./Prod_id/rel/prod/lib.a ./Some_text/rel/fld/lib.a ./Some_text/deb/detail/lib.a ./Some_text/deb/err/lib.a ./Some_text/rel/prod/lib.a ./Some_text/rel/fld/lib.a ./Some_text/deb/detail/lib.a ./Some_text/deb/err/lib.a I want... (5 Replies)
Discussion started by: anand.shah
5 Replies

9. Shell Programming and Scripting

Using sed, awk or perl to remove substring of all lines except the first

Greetings All, I would like to find all occurences of a pattern and delete a substring from the all matching lines EXCEPT the first. For example: 1234::group:user1,user2,user3,blah1,blah2,blah3 2222::othergroup:user9,user8 4444::othergroup2:user3,blah,blah,user1 1234::group3:user5,user1 ... (11 Replies)
Discussion started by: jacksolm
11 Replies

10. Shell Programming and Scripting

Substring Problem with sed . . .

Greetings. I'm looking to isolate the first occurrence of an arbitrary substring which may be present at any particular line in a given file. The enclosing end markers for the target in our thought problem are string" and ". The complete string and surrounding text could look something like... (3 Replies)
Discussion started by: LinQ
3 Replies
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy