Shell Grep和awk的使用

Shell Grep和awk的使用,shell,unix,awk,grep,adb,Shell,Unix,Awk,Grep,Adb,我试过一天,但没修好。我不知道这个方法 content query --uri content://com.android.contacts/contacts | grep "+9053158888" | awk -F'[,,= ]' '{cmd="content delete --uri content://com.android.contacts/contacts/"$(NF-3);system(cmd)}' 但找不到 我的绳子 Row: 99

我试过一天,但没修好。我不知道这个方法

 content query --uri content://com.android.contacts/contacts | grep "+9053158888" |   awk -F'[,,= ]' '{cmd="content delete --uri content://com.android.contacts/contacts/"$(NF-3);system(cmd)}'
但找不到

我的绳子

Row: 9991 last_time_contacted=0, phonetic_name=NULL, custom_ringtone=NULL, contact_status_ts=NULL, pinned=0, photo_id=NULL, photo_file_id=NULL, contact_status_res_package=NULL, contact_chat_capability=NULL, contact_status_icon=NULL, display_name_alt=+90532555688, sort_key_alt=+90532555688, in_visible_group=1, starred=0, contact_status_label=NULL, phonebook_label=#, is_user_profile=0, has_phone_number=1, display_name_source=40, phonetic_name_style=0, send_to_voicemail=0, lookup=0r10070-24121C1814241820221C1A14.3789r10071-24121C1814241820221C1A14.0r10072-24121C1814241820221C1A14.0r10073-24121C1814241820221C1A14.0r10074-24121C1814241820221C1A14.0r10075-24121C1814241820221C1A14.0r10078-24121C1814241820221C1A14.0r10082-24121C1814241820221C1A14.0r10083-24121C1814241820221C1A14.0r10084-24121C1814241820221C1A14.0r10085-24121C1814241820221C1A14.0r10086-24121C1814241820221C1A14.0r10087-24121C1814241820221C1A14.0r10092-24121C1814241820221C1A14.0r10094-24121C1814241820221C1A14.0r10097-24121C1814241820221C1A14, phonebook_label_alt=#, contact_last_updated_timestamp=1612984348874, photo_uri=NULL, phonebook_bucket=213, contact_status=NULL, display_name=+90532555688, sort_key=+90532555688, photo_thumb_uri=NULL, contact_presence=NULL, in_default_directory=1, times_contacted=0, _id=10097, name_raw_contact_id=10070, phonebook_bucket_alt=213

我需要字符串“\u id=10097

来获取所有出现的if try following,并使用GNU
grep
中显示的示例编写和测试。其中
str
是shell变量,其中包含显示的示例输入

echo "$str" | grep -oP ', \K_id=\d+'
或者尝试使用
awk

echo "$str" | 
awk 'match($0,/, _id=[0-9]+/){print substr($0,RSTART+2,RLENGTH-2)}'
以上内容将输出为:

_id=10097

您可以使用此
grep
查找单词
\u id
,后跟一个
=
和1+位:

…|grep-Eo'\b_id=[0-9]+'
_id=10097

请显示
内容查询--uri的输出content://com.android.contacts/contacts
在您的问题中。谢谢这是工作grep-Eo'\u id=[0-9]+'请awk,因为我需要这样的id{cmd=“content delete--uricontent://com.android.contacts/contacts/“$2;系统(cmd)}