splitting value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting splitting value
# 1  
Old 11-25-2011
splitting value

Hello, i want to take a one word from my file.

-- myfile.txt --
test
blablabla
suPHP_ConfigPath /home/performe/etc
blablabla
etc. bla bla.
-- myfile.txt --


How can i take performe from this file ?


Thank you.
# 2  
Old 11-25-2011
Code:
egrep "performe" myfile.txt

Sorry, by the thread title you only need the word, not the line!
# 3  
Old 11-25-2011
Code:
sed -n -e 's:^suPHP_ConfigPath */home/\([^/]*\)/.*$:\1:p'

There are, of course, many, many other ways to do this.
# 4  
Old 11-25-2011
Quote:
Originally Posted by m.d.ludwig
Code:
sed -n -e 's:^suPHP_ConfigPath */home/\([^/]*\)/.*$:\1:p'

There are, of course, many, many other ways to do this.
This command does not stop. I'm waiting a long time for response.

---------- Post updated at 09:27 AM ---------- Previous update was at 09:26 AM ----------

Quote:
Originally Posted by felipe.vinturin
Code:
egrep "performe" myfile.txt

Sorry, by the thread title you only need the word, not the line!
I can't use this command, already i require performe value. I have many files.
# 5  
Old 11-25-2011
Another version...
Code:
awk -F/ '/suPHP/{print $(NF-1)}' input_file

It all depends on the input you paste here...
--ahamed

---------- Post updated at 06:29 AM ---------- Previous update was at 06:28 AM ----------

Quote:
Originally Posted by SAYGIN
This command does not stop. I'm waiting a long time for response.
Because your command is incomplete. You didn't provide the input file!
Code:
sed '...' input_file

--ahamed
# 6  
Old 11-25-2011
Thank you ahamed it's working Smilie

# awk -F/ '/suPHP_ConfigPath/{print $(NF-1)}' myfile.txt
# performe

Quote:
Originally Posted by ahamed101
Another version...
Code:
awk -F/ '/suPHP/{print $(NF-1)}' input_file

It all depends on the input you paste here...
--ahamed

---------- Post updated at 06:29 AM ---------- Previous update was at 06:28 AM ----------


Because your command is incomplete. You didn't provide the input file!
Code:
sed '...' input_file

--ahamed
---------- Post updated at 03:29 PM ---------- Previous update was at 09:31 AM ----------

I have an error with using this command on variable

test.sh

Code:
HFOLDER="awk -F/ '/suPHP_ConfigPath/{print $(NF-1)}' ${HOME}"

test.sh: line 5: NF-1: command not found

How can i solve this ?
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 11-25-2011 at 04:39 PM.. Reason: code tags, please!
# 7  
Old 11-25-2011
Quote:
Originally Posted by SAYGIN
I have an error with using this command on variable

test.sh

HFOLDER="awk -F/ '/suPHP_ConfigPath/{print $(NF-1)}' ${HOME}"

test.sh: line 5: NF-1: command not found

How can i solve this ?
Code:
HFOLDER=`awk -F/ '/suPHP_ConfigPath/{print $(NF-1)}' ${HOME}`

or
Code:
HFOLDER=$(awk -F/ '/suPHP_ConfigPath/{print $(NF-1)}' ${HOME})

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with splitting of file

Hi, I'm beginner in UNIX I would like to split file in separate files depending on Pattern. Input file looks like:-A B C brfbeg A B C brfbeg A B C brfbeg . . n so on (7 Replies)
Discussion started by: Rohit_Mokal
7 Replies

2. Shell Programming and Scripting

Splitting columns

Hi Friends, My input file has more than 20 columns UniProtKB A0A183 LCE6A GO:0031424 GO_REF:0000037 IEA UniProtKB-KW:KW-0417 P Late cornified envelope protein 6A LCE6A_HUMAN|C1orf44|LCE6A protein taxon:9606 20120303 UniProtKB ... (9 Replies)
Discussion started by: jacobs.smith
9 Replies

3. UNIX for Dummies Questions & Answers

Help with file splitting

Hey everyone, I would really appreciate some help with a problem I have filing away some data I have. I have multiple fasta files that have different pieces of information in each. I want to split each file into parts, and then file away each separate part into its own file. Here is an example... (8 Replies)
Discussion started by: Sneeketeeke
8 Replies

4. Shell Programming and Scripting

help in splitting

Hi experts, In the lines below I am trying to copy only the words which come after "//" into an array short nloh; // Comments int age; // Age of the person Please help me in achieving this After the code, the output of the array should Comments Age of the person (6 Replies)
Discussion started by: ramakanth_burra
6 Replies

5. AIX

Splitting the File

Hello I have a requirement where i have to split the file into number of files. Lets say i have 200 records and i need to split the file with 50 records each which would be 4 files. If the file has 60 records then first 50 records in first file and then rest of the 10 records in second file. if... (3 Replies)
Discussion started by: dsdev_123
3 Replies

6. Shell Programming and Scripting

splitting the file

Hi , I have one file which has many headers. Say suppose HEDAER ..data DATA DATA ..data ..data HEADER ..data ..data DATA .data HEADER. ..data ..data If there are 3 HEADERS in source file then I need to split the source file into 3 separate file.... (2 Replies)
Discussion started by: tanyaheerani
2 Replies

7. UNIX for Dummies Questions & Answers

Help splitting file

hi, i was wondering how do i split a large text output file from a keyword, e.g. as soon as 'saveabc.dat' appears in the file. any answers would be much appreciated. thanks:confused: (3 Replies)
Discussion started by: shabs1985
3 Replies

8. UNIX for Dummies Questions & Answers

splitting the files

Hi, I have some files with 2 million odd records which i need to split into chunks of 0.5 millions. I have the file sorted with a key column in order. The same key value can appear as 4 or 5 records in the file. Hence after splitting we are checking whether all the key values are present in the... (5 Replies)
Discussion started by: dnat
5 Replies

9. Shell Programming and Scripting

splitting a file

I have a huge file with 13 million records , how do i split this file into 13 files which has 1 million records in each ( each record is one line) I tried this but how to print the second million etc cat file | head -1000000 > file1 cat file | tail -1000000 >file13 please shed some... (1 Reply)
Discussion started by: ramky79
1 Replies

10. Shell Programming and Scripting

Need help in splitting the file

Hi, I got a file which may have 100 - 500 rows with header and trailer... based on the total number of real rows ( excluding header and trailer) I want to break the file in 3 or 4 files .. Coded like this .. but giving error in the AWK in 8th line of below code. awk 'NR > 5 {print line}... (3 Replies)
Discussion started by: Vaddadi
3 Replies
Login or Register to Ask a Question