10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to remove double quoted strings from specific lines in a file. The specific line numbers are a variable. For example, line 5 of the file contains
A B C "string"
I want to remove "string". The following sed command works:
sed '5 s/\"*\"//' $file
If there are multiple... (2 Replies)
Discussion started by: rennatsb
2 Replies
2. Shell Programming and Scripting
Objective is to substitute Jan with 01, Feb with 02 and so on. The month will be provided as input.
I could construct below awk and it worked.
echo Jun | \
awk 'BEGIN{split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",mon," ")}{ for (i=1;i<=12;i++){ if ($1==mon) printf("%02d\n",i)} }'
... (4 Replies)
Discussion started by: krishmaths
4 Replies
3. Shell Programming and Scripting
Hi All,
Can you please guide me to search a string in a particular column of file and return the line number of the line where it was found using awk. As an example :
abc.txt
7000,john,2,1,0,1,6
7001,elen,2,2,0,1,7
7002,sami,2,3,0,1,6
7003,mike,1,4,0,2,1
8001,nike,1,5,0,1,8... (3 Replies)
Discussion started by: arunshankar.c
3 Replies
4. Shell Programming and Scripting
Hi guys,
is there are way to substitute the content of certain line in the file by another entry if line number is available?
For example, I have a variable A="HCMLPBBG" and a file MYFILE.
I need to substitute entry on line 18168 of MYFILE with the value of the variable "A".
Is there a way to... (1 Reply)
Discussion started by: aoussenko
1 Replies
5. Shell Programming and Scripting
If I have a file something like as shown below,
ARM*187878*hjhj
BAG*88778*jjjj
COD*7777*kkkk
BAG*87878*kjjhjk
DEF*65656*89989*khjkk
I need the line numbers to be added with a colon when it matches the string "BAG". Here in my case, I need something like
ARM*187878*hjhj... (4 Replies)
Discussion started by: Muthuraj K
4 Replies
6. Shell Programming and Scripting
I have a code here , which should display lines 6,10,14,18,35 of a text file
#!/bin/ksh
line=6
line=10
line=14
line=18
line=35
for i in 1 2 3 4 5
do
val=`echo ${line}`
act=`awk 'NR~/^($val)$/' db_CHECKOUT.txt`
done;
This code is not working. The purpose of the line below is... (3 Replies)
Discussion started by: njafri
3 Replies
7. Shell Programming and Scripting
Hi all,
I want to display line number for matching string in a file. can anyone please help me.
I used
grep -n "ABC" file
so it displays
6 ABC.
But i only want to have line number,i don't want that it should prefix matching context with line number.
Actually my original... (10 Replies)
Discussion started by: sarbjit
10 Replies
8. Shell Programming and Scripting
Hi All,
I'm new to unix shell scripting.. Could someone guide me.
I have to search a string in the entire directory, once the search string is matched, it should print the line number of the string that matches and also the line and along with
it, it should print the file name.
Thanks,... (5 Replies)
Discussion started by: thenz
5 Replies
9. Shell Programming and Scripting
Suppose,
d=ABC*.BGH.LKJ
Now I want to replace 'DEFGHIJ' instead of '*.B' and store the value in d. Any Idea? Can we use sed here?
The outout should be like this:
d=ABCDEFGHIJGH.LKJ
Please help.. (4 Replies)
Discussion started by: Niroj
4 Replies
10. Shell Programming and Scripting
Dear Masters,
Here i have some doubts can anyone clarify?.
Is it possible to grep the lines by specifying the line numbers.
I know the line number which i want to grep.
example:
grep 40th line filename
grep 50th line filename
Need ur comments. (4 Replies)
Discussion started by: salaathi
4 Replies