shell 多行合并 或多行提取

发布于 2022-09-12 13:11:23 字数 2691 浏览 12 评论 0

各位大佬,目前有类似这样的文件:import 和from 可能在一行,也可能不在一行,是多行

import React, {Component} from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    View,
    FlatList,
    TouchableHighlight,
    DeviceEventEmitter,
    Animated,
    BackHandler
} from 'react-native';
import {
    UPTrackEvent
} from' up-rn-base/action/UPModules'
import {
    kkjhhhhh,
    jhhjjhhhh,
    kkkkkk
} from 'up-rn-base/action/UPModules'
import {oooooo} from 'up-rn-base/action/UPModules'
import {ppppp} from 'up-rn-base/action/UPModules'

import OrderBar from '../views/OrderBar'
import OrderList from '../views/OrderList'
import OrderUtils from '../views/OrderUtils'
import ViewLoading from "up-rn-base/views/LoadingComponent"
import FailureComponent from "up-rn-base/views/FailureComponent"
import UPReactTitle from 'up-rn-base/views/UPNativeTitle'
import RNText from 'up-rn-base/component/UPWRNText'
import UPMultiLanguageConfig from '../config/UPMultiLanguageConfig'

let dimensions = require("Dimensions");
let {width, height} = dimensions.get("window");
const BAR_HEIGHT = 42;
export default class List extends Component {

我想提取出from后是up-rn-base路径及对应的import 和from 之间的内容,最后提取的结果类似这样:

UPTrackEvent up-rn-base/action/UPModules
kkjhhhhh up-rn-base/action/UPModules
jhhjjhhhh up-rn-base/action/UPModules
kkkkkk up-rn-base/action/UPModules
oooooo up-rn-base/action/UPModules
ppppp up-rn-base/action/UPModules
ViewLoading up-rn-base/views/LoadingComponent
FailureComponent up-rn-base/views/FailureComponent
UPReactTitle up-rn-base/views/UPNativeTitle
RNText up-rn-base/component/UPWRNText

目前用了

awk '/import/,/from/{print $0}'

只能到这个结果:

import {
    Platform,
    StyleSheet,
    Text,
    View,
    FlatList,
    TouchableHighlight,
    DeviceEventEmitter,
    Animated,
    BackHandler
} from 'react-native';
import {
    UPTrackEvent
} from' up-rn-base/action/UPModules'
import {
    kkjhhhhh,
    jhhjjhhhh,
    kkkkkk
} from 'up-rn-base/action/UPModules'
import {oooooo} from 'up-rn-base/action/UPModules'
import {ppppp} from 'up-rn-base/action/UPModules'
import OrderBar from '../views/OrderBar'
import OrderList from '../views/OrderList'
import OrderUtils from '../views/OrderUtils'
import ViewLoading from "up-rn-base/views/LoadingComponent"
import FailureComponent from "up-rn-base/views/FailureComponent"
import UPReactTitle from 'up-rn-base/views/UPNativeTitle'
import RNText from 'up-rn-base/component/UPWRNText'
import UPMultiLanguageConfig from '../config/UPMultiLanguageConfig'

网上搜了,及看了多行匹配相关的内容,还是搞不出来。
目前想着把相邻的import from 整成一行再提取。

恳请大佬,根据关键字对行合并成一行怎么写呢,或者怎么能的呆我想要的结果呢。非常感谢。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文