about the modify lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting about the modify lines
# 1  
Old 12-28-2009
about the modify lines

Hello,

I am trying to convert lines from text file, I got lines in text files like that

PHP Code:
ALPHA.cab
tomtom
.cab
vgame
.cab
converter
.cab 
What i want to do is I want to conver these lines like that,


PHP Code:
cabwiz.exe   ALPHA.cab  extract  "C:\1extract\ALPHA"
cabwiz.exe   tomtom.cab  extract  "C:\1extract\tomtom"
cabwiz.exe   vgame.cab  extract  "C:\1extract\vgame"
cabwiz.exe   converter.cab  extract  "C:\1extract\converter" 
been trying for long with little knowledge, if anybody can fiind solution, that will be great.


Many thanks
# 2  
Old 12-28-2009
Enjoy the below SmilieSmilieSmilieSmilieSmilie :-

Code:
nawk '{ $1=$1 ; match($1,/\./) ;
printf "cabwiz.exe   %-15s extract \"C:\\1extract\\%s\"\n",$1,substr($1,1,RSTART-1) }
' infile.txt > outfile.txt

SmilieSmilie
# 3  
Old 12-28-2009
or

Code:
while read LINE; do echo "cabwiz.exe   $LINE  extract  \"C:\\1extract\\${LINE%.*}\""; done < file

# 4  
Old 12-28-2009
Another one:
Code:
awk '{
  split($0,a,".")
  printf("cabwiz.exe\t%s\textract\t\"C:\\1extract\\%s\"\n",$0,a[1])
}' file

# 5  
Old 12-28-2009
Many thanks for all reply all work great.
# 6  
Old 12-28-2009
Quote:
Originally Posted by anchal_khare
or

Code:
while read LINE; do echo "cabwiz.exe   $LINE  extract  \"C:\\1extract\\${LINE%.*}\""; done < file

Code:
If you are looking for the faster code then choose anchal_khare code
 otherwise you can choose either Franklin52 or my code;
they are approximately taking the same time in execution.

BR
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ed to modify a file --- or not?

Running Oracle Linux 6 (derivative of RHEL 6) Given this snippet of code in a shell script: #-- reset oratab to use 11.2 home for dwdev #-- normally we'd just use sed to do this sort of thing, but that would #-- require permissions that we don't have in the /etc/ directory, so we #-- ... (3 Replies)
Discussion started by: edstevens
3 Replies

2. Shell Programming and Scripting

awk repeat one field at all lines and modify field repetitions

Hello experts I have a file with paragraphs begining with a keeping date and ending with "END": 20120301 num num John num num A keepnum1 num num kathrin num num A keepnum1 num num kathrin num num B keepnum2 num num Pete num num A keepnum1 num num Jacob num... (2 Replies)
Discussion started by: phaethon
2 Replies

3. UNIX for Dummies Questions & Answers

How to modify an output?

I have a list XPAR XPAR XPAR , XPAR , , XPAR ,1, XPAR 196 XPAR 95 XPAR 95,77 This has space and tabs on the second row. I would like it to look like XPAR 1, 196, 95, 77 But I always get the below because of the spaces above. , , ,1, 196 95 95,77 I use... (9 Replies)
Discussion started by: priyanka.premra
9 Replies

4. UNIX for Dummies Questions & Answers

How to modify lines without certain patterns?

I have file like this: rs111 A T 0.9 0.8 ... rs112 AT T 0.8 0.2 ... rs113 G CT 0.9 0.1... I wish to replace all the NONE "A" or "T" or "G" or "C" values in column 3 and column 4 to " ", how can I do this? thanks! (8 Replies)
Discussion started by: luoruicd
8 Replies

5. Shell Programming and Scripting

modify a format

Hi I have a format that looks like this: #TailType TwoSided #Scale to target True #Target Intensity 100 #Intensities PM/MM #Treatment CEL ./G.CEL #Control CEL ./F.CEL chr1 16 0 chr1 24 0 chr1 32 0.187188 chr1 40 0.14595 chr1 ... (5 Replies)
Discussion started by: kylle345
5 Replies

6. Shell Programming and Scripting

Perl - need script for modify lines

Hello, does somebody can make script for me, which replace: ąćę ąćę ąćę (input file) to ace;|;ąćę ace;|;ąćę ace;|;ąćę (output file) (3 Replies)
Discussion started by: Xadrian
3 Replies

7. Shell Programming and Scripting

How to modify the variable

I have a directory name stored in a variable. Does anyone have a piece of code which checks if this stored directory name ends up with the "/" and if it is missing adds it to the same variable. for example I might have A=/bb/data or A=/bb/data/ which needs to be A=/bb/data/ for sure thanks... (5 Replies)
Discussion started by: aoussenko
5 Replies

8. UNIX for Dummies Questions & Answers

How to use sed modify specific lines

Could anybody tell me how I can use sed to modify lines following specific lines? the file is as following: "TEST/SI1573.lab" 3670 8920 h# 8920 9530 hh 9530 10694 ih . "TEST/DR1/FAKS0/SI2203.lab" 9730 9580 h# 9580 9840 dh 9840 10652 ix 10652 11997 r ........ I want to modify the... (5 Replies)
Discussion started by: Jenny.palmy
5 Replies

9. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

10. UNIX for Advanced & Expert Users

Modify A Program

hi all, I'm sorry for my english. I have this problem: I and my collegues can modify the same file at the same time. Is it possible delete this problem? The editor is VI. thanks. (4 Replies)
Discussion started by: tullo
4 Replies
Login or Register to Ask a Question