help with cut word


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with cut word
# 1  
Old 06-02-2008
help with cut word

hi there i have this problem , i need cut the 4 first character and the 6 last characters of the word

this is my file

'dg_bancdist_logs'
'dg_tibco_logs'
'dg_rmp_logs'
'dg_mig_logs'
'dg_titan_logs'
'dg_swift_logs'
'dg_isis_logs'
'dg_isisges_logs'

and i need this


bancdist
tibco
rmp
mig
titan
swift
isis
isisges
# 2  
Old 06-02-2008
try this:
Code:
cut -d '_' -f 2 filename

# 3  
Old 06-02-2008
Code:
for i in <filename>
do
j=i | cut -d "_" -f 2
done

j variable will have your desired values..
# 4  
Old 06-02-2008
awk -F"_" '{print $2}' <filename>
# 5  
Old 06-02-2008
Quote:
Originally Posted by nua7
Code:
for i in <filename>
do
j=i | cut -d "_" -f 2
done

j variable will have your desired values..
see post #2
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Cut a word between two strings and repeat the same in the entire file

in the below data i need to search for the word typeMismatch and then traverse back to find the filename of that particular mismatch. Like this we have to get all the file names which has error in them. How can i acheive this. I tried use sed or awk but not able to achevie the same. Sample... (2 Replies)
Discussion started by: ATWC
2 Replies

2. Shell Programming and Scripting

Cut & Fetch word from string

I have a file with some SQL query, I want to fetch only Table Name from that file line by line. INPUT FILE SELECT * FROM $SCHM.TABLENAME1; ALTER TABLE $SCHM.TABLENAME1 ADD DateOfBirth date; INSERT INTO $SCHM.TABLENAME1 (CustomerName, Country) SELECT SupplierName, Country FROM $SCHM.TABLENAME2... (2 Replies)
Discussion started by: Pratik Majithia
2 Replies

3. UNIX for Advanced & Expert Users

cut words based on the word count of a line

I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. https://www.unix.com/shell-programming-scripting/105841-count-words-each-line-file-using-xargs.html If the line has 6 words I would like to use this.... (8 Replies)
Discussion started by: cokedude
8 Replies

4. UNIX for Advanced & Expert Users

use a word as a delimiter with cut

Is there a way to use a word as a delimiter with cut? Or is there a way to use sed or awk with a word as a delimiter? I don't care which program I use for a delimiter I just want to use a word as a delimiter. (2 Replies)
Discussion started by: cokedude
2 Replies

5. Shell Programming and Scripting

cut the first word in the file

how to cut the first word in multiple file at a time i.e)1st row and 1st colum word in multiple files (6 Replies)
Discussion started by: natraj005
6 Replies

6. Shell Programming and Scripting

Script to cut the first word in Message Text

Hi, In my shell script, I am connecting to database and querying multiple columns in a table. MESSAGE_TEXT=`sqlplus -s /nolog <<end_log_stmt set heading off set feedback off set verify off set termout off set pages 0 CONNECT APPS/$USER_PWD Select order_number, id, error_message... (6 Replies)
Discussion started by: balajiora
6 Replies

7. 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

8. Shell Programming and Scripting

Sed or awk cut all lines after word

Hi, sorry for newbie question :confused: can't find how to cut ? from 1000 2000 word some text1.... 100 200 300 word some text2.... 10 20 30 abc word some text3.... to some text1.... some text2.... some text3.... (7 Replies)
Discussion started by: Trump
7 Replies

9. Shell Programming and Scripting

script to cut a word from the file

hi to all i wrote a script to cut a word from the file....that works only if the word is fixed field. example.. sed -n '1p'|awk '{ print $2 }'|cut -d '(' -f2|sed 's/(//'|sed 's/)//'|sed 's/"//g' filename i know that word is starting with "app" then "(" ----> ex: app("xxxx"). it... (2 Replies)
Discussion started by: honeym210
2 Replies

10. Shell Programming and Scripting

cut last line of a word

Hi all, want to delete a crahecter from each line..? how can i do it... (2 Replies)
Discussion started by: bullz26
2 Replies
Login or Register to Ask a Question