awk/grep or parsing in python code


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk/grep or parsing in python code
# 1  
Old 02-06-2012
Question awk/grep or parsing in python code

Hello,
I am writing a python code. The output of the python code needs a little bit of parsing. From the output of python code, which has a lot of redundant data, I need to cut only those words or numbers which end with &. for example: if the output is--

"This is an example of tgbn123& what i need to get"

I need to write tgbn123 in a text file. Is is possible using grep or awk in python? If so, how? :s
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python script to grep fields and use values from file 1 as argument for another command

Hi Experts, I am working one one python script in version 3.x and 2.6. Need your support to complete it Basically for both commands i have telnet to device and run command and then receiving input File 1 and File 2 I have two commands, need to grep data and output in csv file. Next script/code... (0 Replies)
Discussion started by: as7951
0 Replies

2. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies

3. UNIX for Dummies Questions & Answers

sed or Grep Parsing

I would like to parse two strings from lines in a file only when both strings appear on the same line. For example, if I have the following line: string1 string2 string3 string4 string5 string6 string7 string8 string9 I would like the output to be: string2: string7 Can someone give me... (5 Replies)
Discussion started by: ARBlue79
5 Replies

4. Shell Programming and Scripting

Pick first "code" only [ grep/awk ]

All I have a requirement to search and pick the data as below. Explained with example. 38999|4812 Highway 52 North|Rockville|55901|0196 67541|2800 Dexter Road|Northville|38999|0196 This is pipe separate data. First column represents dealer id and 4th column represents the zip code where... (4 Replies)
Discussion started by: ak835
4 Replies

5. Programming

Python: Parsing and comparing XMLs with minidom

Hi there! I'd like to parse and compare 2 XML files with the minidom parser as follows: I have 2 XML files with loads of data. One is in English (the source file), the other one the corresponding French translation (the target file). E.g.: source file: <macro> <id> 123</id> ... (0 Replies)
Discussion started by: Bloomy
0 Replies

6. Shell Programming and Scripting

parsing string into grep

I'm using sh under AIX 5.3 and after grep'ing, awk'ing, splitting a file, I end up with two variables as: 0123456 789Can these values be somehow passed into a grep as two different variables using xargs or something? What I want to do is this (the echo is just for effect here): echo 0123456 789... (2 Replies)
Discussion started by: say170
2 Replies

7. Programming

Parsing command line arguments in Python

Hi, I've a python script called aaa.py and passing an command line option " -a" to the script like, ./aaa.py -a & Inside the script if the -a option is given I do some operation if not something else. code looks like ./aaa.py -a . . if options.a ---some operation--- if not options.a... (1 Reply)
Discussion started by: testin
1 Replies

8. Shell Programming and Scripting

Parsing out access.log with awk and grep

In part of my script I use awk to pull out the urls. awk '{print $8}' then I take them and send them to grep.` Some of them are straight .com/ or .org or whatever (address bar entries), while others are locations of images, js, etc. I'm trying to only pull any line that ends with .com/... (11 Replies)
Discussion started by: druisgod
11 Replies

9. Programming

Needing help parsing XML/RDF using Python

Hello, I am trying to make script to parse the install.rdf files found in firefox xpi extentions to isolate the extention ID so I can name a directory and automate installation of system-wide extension. I am very facile with the command line, but not with programming languages (esp... (0 Replies)
Discussion started by: Narnie
0 Replies

10. Shell Programming and Scripting

Using GREP in PYTHON

Hello All, I currently have the following python code: #usr/bin/python import os variable=raw_input('Search for this string: ') os.system("grep $variable sample.txt") Basically what I want to do is to grep a string found in the text file "sample.txt" When I run the code, it just hangs.... (1 Reply)
Discussion started by: jl487
1 Replies
Login or Register to Ask a Question
UPDATE-PYTHON-MODULES(8)				      System Manager's Manual					  UPDATE-PYTHON-MODULES(8)

NAME
update-python-modules - byte-compile python modules SYNOPSIS
update-python-modules [options] [package.public [...]] DESCRIPTION
The update-python-modules command is part of the python-support bundle. update-python-modules is responsible for the byte-compilation of python modules. When used in byte-compilation mode, it will byte-compile modules references in the files given on the command line. When used in installation mode, it will byte-compile them once for each installed python version, and will make them available for all of them. At each invocation, with or without arguments, update-python-modules will check for installed python versions, and will build or remove modules according to new or removed versions since the last time it was run. ARGUMENTS
Arguments must be files or directories located in the /usr/share/python-support directory. Depending on their extension, they are treated differently. package.public A file listing public modules to install for each version. These modules must lie in /usr/share/pyshared or /usr/lib/pyshared. package.private A file listing private modules to byte-compile for one Python version. package/ A legacy directory hierarchy of public modules. The C extensions and portions that change with the Python version are to be found in /usr/lib/python-support/pythonX.Y/package/. package.dirs A legacy file listing directories where to find private modules. OPTIONS
-h, --help Show summary of options. -v, --verbose Detail all actions while they are performed. -b, --bytecompile Only accept to work on private modules. When given this option, update-python-modules will fail if passed references to public mod- ules. -i, --install Only accept to work on public modules. When given this option, update-python-modules will fail if passed references to public mod- ules. -c, --clean Clean modules instead of installing them. -a, --rebuild-all Rebuild all private modules. This is necessary when the default python version was changed, for example. -f, --force-rebuild-all Clean all modules (public and private), and rebuild them. FILES
/usr/lib/pymodules/pythonX.Y/ These directories contain the byte-compiled modules for version pythonX.Y. SEE ALSO
/usr/share/doc/python-support/README.gz AUTHOR
Josselin Mouette <joss@debian.org>. 18 Feb 2009 UPDATE-PYTHON-MODULES(8)