我有一个带有以下这些行的文本文件(A.txt):
operator()
和其他文本文件(B.txt)一起使用以下这些行:
Aaaaaaa1
Aaaaaaa2
Aaaaaaa3
我想以这种方式将A.txt和B.txt结合在其他文件(OUTCOME.txt)中:
Bbbbbbb1
Bbbbbbb2
Bbbbbbb3
如何使用读取,grep,echo等在Linux中使用bash shell进行此操作?
答案 0 :(得分:2)
只需paste
即可:
$ cat file1
Aaaaaaa1
Aaaaaaa2
Aaaaaaa3
$ cat file2
Bbbbbbb1
Bbbbbbb2
Bbbbbbb3
$ paste -d $'\n' file1 file2
Aaaaaaa1
Bbbbbbb1
Aaaaaaa2
Bbbbbbb2
Aaaaaaa3
Bbbbbbb3
答案 1 :(得分:1)
使用GNU sed:
sed 'R b.txt' a.txt > OUTCOME.txt
输出到OUTCOME.txt:
Aaaaaaa1 Bbbbbbb1 Aaaaaaa2 Bbbbbbb2 Aaaaaaa3 Bbbbbbb3
答案 2 :(得分:1)
使用import tkinter as tk
root = tk.Tk()
# Change the original tkinter icon
root.iconbitmap('C:\\Users\\bmxfi\Downloads\images.ico')
# Set the title of the window
root.title('Calculator')
# Change the geometry of the window
root.geometry('300x450+750+150')
# Setting Minimum and Maximum window width and height
root.minsize(width=300, height=450)
root.maxsize(width=300, height=450)
# Create Rows and Columns to display widgets
root.rowconfigure(0, weight=100)
root.rowconfigure(1, weight=100)
root.rowconfigure(2, weight=100)
# Columns start here:
root.columnconfigure(0, weight=100)
root.columnconfigure(1, weight=100)
root.columnconfigure(2, weight=100)
# Configuring the Main window named: root
root.configure(bg='#353535')
# Creating the main label that will display the calculated results
lab_1 = tk.Label(root, width=40)
lab_1.grid(row=0, column=1, columnspan=1, sticky='we')
lab_1.configure(bg='#545454', font=('Computer Modern', 25, 'bold'),
fg='White', justify='right')
# Main Calculator Layout
# List Box for a calculator layout
box_1 = tk.Listbox(root)
box_1.grid(row=1, column=1, rowspan=2)
box_1.configure(bg='#353535', relief='flat')
# Button Layout
calculator_layout = [[(7, 1), (8, 1), (9, 1), ('(', 1), (')', 1)],
[(4, 1), (5, 1), (6, 1), ('×', 1), ('÷', 1)],
[(1, 1), (2, 1), (3, 1), ('+', 1), ('-', 1)],
[(0, 1), ('±', 1), ('.', 1), ('-', 1), ('=', 1)]]
# Iterating through my list to get a set of buttons
row = 0
for i in calculator_layout:
col = 0
for a in i:
key_press = tk.Button(box_1, text=a[0])
key_press.grid(row=row, column=col, ipadx=10, ipady=8, sticky='we')
key_press.configure(background='#545454', fg='white',
font=('Computer Modern', 10),
activebackground='red', state='normal')
col += a[1]
row += 1
root.mainloop()
和echo
:
read
第二个while IFS= read -r line1 && IFS= read -ru3 line2; do
echo "$line1"
echo "$line2"
done < file1 3< file2
使用不同的文件描述符(在这种情况下为read
)非常重要。
答案 3 :(得分:0)
keys[j] = keys[j-1];
keys[j-1] = keys[j-2];
keys[j-2] = keys[j-3];
...
keys[i+1] = keys[i];
+ paste
解决方案(适用于您当前的输入文件):
awk