Sponsored Content
Top Forums Shell Programming and Scripting How to cut first line only from a text near a specific column without cutting a word Post 302316375 by ghostdog74 on Thursday 14th of May 2009 11:08:41 PM
Old 05-15-2009
ok so you are only processing the first line. If you have Python,
Code:
#!/usr/bin/env python
f=open("file")
firstline=f.readline().strip()[:19]
print firstline
for line in f: print line.strip()
f.close()

output:
Code:
# ./test.py
balah bb 213112312
ah bb 213112312 12321 balah bb 213112312 12321 balah bb 213112312 123
ah bb 213112312 12321 balah bb 213112312 12321 balah bb 213112312 123
b 213112312 12321 balah bb 213112312 12321 balah bb 213112312 12321
ah bb 21311b 213112312 12321 balah bb 213112312 12321 balah bb 213112312 12321
ah bb 21311b 21b 213112312 12321 balah bb 213112312 12321 balah bb 213112312 12321
ah bb 21311b 213112b 213112312 12321 balah bb 213112312 12321 balah bb 213112312 12321
ah bb 21311

else:
Code:
# awk 'NR==1{print substr($0,1,19);next}1' file

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

cut a specific value from a column

Dear Friends, I have an output like this: 7072;0;7072901 7072;1001;7072902 7072;101;7072903 7072;102;7072904 7072;1101;7072905 7072;1301;7072906 7072;1401;7072907 7072;162;7072908 7072;1;7072909 and I need to print the value in the column 3 , row number 1. which is 7072901 only.... (2 Replies)
Discussion started by: sfaqih
2 Replies

2. Shell Programming and Scripting

How to replace a specific word in specific column?

Hi My orginal file is like (100s of lines) id host ip location remarks 1 host1 ip1 - xxx 2 host2 ip2 - xxx 3 host3 ip3 - xxx -- -- 9 host9 ip9 - xxx I have a ref file like host1 location1 host2 location2 host3 location3 -- --... (6 Replies)
Discussion started by: ./hari.sh
6 Replies

3. Shell Programming and Scripting

Help need to cut the first word of a line in text file

Hi All, I would like help with a script which can get rid of the first work of all lines in text file. File 1 The name is Scott. Output : name is Scott ---------- Post updated at 02:38 PM ---------- Previous update was at 02:37 PM ---------- Hi ALL There is typo error in... (3 Replies)
Discussion started by: bubbly
3 Replies

4. Shell Programming and Scripting

Cutting specific line of a file by checking condition

testfile.csv 0","1125209",,"689202CBx18888",,"49",,,"NONMC",,,,,"01112010",,,,,,,"MTM- "1","",,"689202ABx19005",,"49",,,"NONMC",,,,,"01072010",,,,,,,"MTM- testfile.csv looks like above format if the second column is null then get 23rd column and store in a different varible .. add all the... (1 Reply)
Discussion started by: mgant
1 Replies

5. Shell Programming and Scripting

Cutting out text from specific portion on filename

Hi, how do I go about cutting out the first numeric characters after the word "access"? access1005101228.merged-00.15.17.86.d8.b8.log.gz (16 Replies)
Discussion started by: GermanJulian
16 Replies

6. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

7. UNIX for Dummies Questions & Answers

How to cut from a text file based on value of a specific column?

Hi, I have a tab delimited text file from which I want to cut out specific columns. If the second column equals one, I want to cut out columns 1 and 5 and 6. If the second column equals two, I want to cut out columns 1 and 5 and 7. How do I go about doing that? Thanks! (4 Replies)
Discussion started by: evelibertine
4 Replies

8. Shell Programming and Scripting

How to print multiple specific column after a specific word?

Hello.... Pls help me (and sorry my english) :) So I have a file (test.txt) with 1 long line.... for example: isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh How to print after the "error" word the 2nd 4th 5th and 7th word?? output well be: 653 isfbisfb... (2 Replies)
Discussion started by: marvinandco
2 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

10. UNIX for Beginners Questions & Answers

Cut specific column from 2 file and merge

Hi ALL, I have two file. I need to combine these two file based on a layout. I used the below code and able to extract the record. But now able to insert that to a 3'rd file in between the extract FILE 1 CAID NUMBER 1-20 TID NUMBER 21-22 LABEL CHAR 23-44 BASE 45-60... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
KROSS(1)							 KDE User's Manual							  KROSS(1)

NAME
kross - KDE application to run kross scripts. SYNOPSIS
kross [--help] [Generic-options] [Qt-options] [KDE-options] [file ...] DESCRIPTION
kross executes kross scripts written in KDE Javascript, Python, Ruby, Java and Falcon. GENERIC OPTIONS
--author Show author information. --help Show help about options. --help-all Show all options. --help-kde Show KDE specific options. --help-qt Show Qt specific options. --license Show license information. -v--version Show version information APPLICATION OPTIONS
file... The files with the scripts to run. USAGE
kross file runs the script in file after loading the interpreter plugin for the script language (detected by filename suffix). To interpret other languages than KDE Javascript, kdebindings must be installed. SEE ALSO
kdeoptions(7), qtoptions(7), python(1), ruby(1), kjs(1), java(1), falcon(1) Look at http://kross.dipe.org/solution.html for more information and tutorials. BUGS
There are probably tons of bugs. Use bugs.kde.org: http://bugs.kde.org to report them. AUTHOR
Sebastian Sauer <mail@dipe.org>. 2008-10-22 KROSS(1)
All times are GMT -4. The time now is 10:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy