10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello All;
I have an input file 'abc.txt' with below text:
512345977,213458,100021
512345978,213454,100031
512345979,213452,100051
512345980,213455,100061
512345981,213456,100071
512345982,213456,100091
512345983,213457,100041
512345984,213451,100011
I need to paste the first field... (10 Replies)
Discussion started by: mystition
10 Replies
2. Shell Programming and Scripting
How to match a shell variable that contains parenthesis (and other special characters like "!")
file.txt contains:
Charles Dickens
Matthew Lewis (writer)
name="Matthew Lewis (writer)";
awk -v na="$name" ' $0 ~ na' file.txt
Ideally this would match $name in file.txt (in this... (3 Replies)
Discussion started by: Mid Ocean
3 Replies
3. Shell Programming and Scripting
Hello life savers!!
Is there any way to use substr in awk command for returning one part of a string from declared start and stop point?
I mean I know we have this:
substr(string, start, length)
Do we have anything like possible to use in awk ? :
substr(string, start, stop)
... (9 Replies)
Discussion started by: @man
9 Replies
4. Shell Programming and Scripting
Hi to all,
I'm here again, cause I need your help to solve another issue for me.
I have some files that have this name format: date_filename.csv
In my shell I must rename each file removing the date so that the file name is filename.csv
To do this I use this command:
fnames=`ls ${fname}|... (2 Replies)
Discussion started by: leobdj
2 Replies
5. Shell Programming and Scripting
Hi All,
I have a fixed-width datafile from which i need to extract value/string starting from some position to the specified length in each of the lines.
awk '{print substr($0,x,y)}' datafile --- is working fine
but
awk 'BEGIN{a=0}{a=substr($0,x,y);print $a}' datafile ---is giving... (3 Replies)
Discussion started by: loggedin.ksh
3 Replies
6. Shell Programming and Scripting
I have the following to find lines matching "COMPLETE" and extract parts of it using substr.
sed -n "/COMPLETE/p" 1.txt | awk 'BEGIN { FS = "\" } {printf"%s %s:%s \n", substr($3,17,3),substr($6,4,1), substr($7,4,1)}' | sort | uniq > temp.txt
Worked fine until the numbers in 2nd & 3rd substr... (5 Replies)
Discussion started by: zpn
5 Replies
7. Shell Programming and Scripting
I'm writing a shell script in which I need to be able to pull a portion of the file name out. I'm testing with the following code:
x="O1164885.DAT"
y=`ls -ltr *${x}|awk '{print substr($0,3)}'`
echo ${x}|awk '{print substr($0,3)}'
echo "y="$y
I can echo it to the screen just fine but I... (3 Replies)
Discussion started by: ttunell
3 Replies
8. Shell Programming and Scripting
Hi
I have multiple files that name begins bidb_yyyymm. (yyyymm = current year month of file creation).
What I want to do is look at the files and where yyyymm is older than 1 month I want to remove the file from the server.
I was looking at looping through the files and getting the yyyymm... (2 Replies)
Discussion started by: colesga
2 Replies
9. Shell Programming and Scripting
Hi all,
I have a flatfile
I would like to get ext = 7950 , how do I do that ?
if ($1 == "CTI-ProgramStart") {
ext = substr($9,index($9,"Extension")+11,4);
But why it is not working ???? Please help .
Thanks (1 Reply)
Discussion started by: sabercats
1 Replies
10. Shell Programming and Scripting
Dear All,
I am new to Unix and need your help. I am trying to write b-shell script which will return substr of some variable like this
d="asdfg"
return Substr(d,1,5).
Please help (5 Replies)
Discussion started by: giviut
5 Replies